From 1267fb4e3b818d05d261eceef82d5137ef01360c Mon Sep 17 00:00:00 2001 From: SergeyNefyodov Date: Tue, 28 Nov 2023 13:25:06 +0400 Subject: [PATCH 1/4] Object members support added --- RevitLookup/Core/Metadata/DescriptorBuilder.Build.cs | 2 ++ RevitLookup/Services/Contracts/ISettingsService.cs | 1 + RevitLookup/Services/SettingsService.cs | 7 +++++++ RevitLookup/Views/Pages/SnoopViewBase.xaml.cs | 9 ++++++++- 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/RevitLookup/Core/Metadata/DescriptorBuilder.Build.cs b/RevitLookup/Core/Metadata/DescriptorBuilder.Build.cs index d2aa0cdc3..91f20576b 100644 --- a/RevitLookup/Core/Metadata/DescriptorBuilder.Build.cs +++ b/RevitLookup/Core/Metadata/DescriptorBuilder.Build.cs @@ -34,6 +34,8 @@ private IReadOnlyCollection BuildInstanceObject(Type type) types.Add(type); type = type.BaseType; } + if (_settings.IsObjectMembersAllowed) + types.Add(typeof(object)); for (var i = types.Count - 1; i >= 0; i--) { diff --git a/RevitLookup/Services/Contracts/ISettingsService.cs b/RevitLookup/Services/Contracts/ISettingsService.cs index 02aa54753..6c4c555af 100644 --- a/RevitLookup/Services/Contracts/ISettingsService.cs +++ b/RevitLookup/Services/Contracts/ISettingsService.cs @@ -37,6 +37,7 @@ public interface ISettingsService bool IsEventsAllowed { get; set; } bool IsExtensionsAllowed { get; set; } bool IsTimeColumnAllowed { get; set; } + bool IsObjectMembersAllowed { get; set; } int ApplyTransition(bool value); void Save(); diff --git a/RevitLookup/Services/SettingsService.cs b/RevitLookup/Services/SettingsService.cs index cb64e933b..10beb2abb 100644 --- a/RevitLookup/Services/SettingsService.cs +++ b/RevitLookup/Services/SettingsService.cs @@ -46,6 +46,7 @@ internal sealed class Settings public bool IsFieldsAllowed { get; set; } public bool IsEventsAllowed { get; set; } public bool IsExtensionsAllowed { get; set; } + public bool IsObjectMembersAllowed { get; set; } } public sealed class SettingsService : ISettingsService @@ -131,6 +132,12 @@ public bool IsExtensionsAllowed get => _settings.IsExtensionsAllowed; set => _settings.IsExtensionsAllowed = value; } + + public bool IsObjectMembersAllowed + { + get => _settings.IsObjectMembersAllowed; + set => _settings.IsObjectMembersAllowed = value; + } public int ApplyTransition(bool value) { diff --git a/RevitLookup/Views/Pages/SnoopViewBase.xaml.cs b/RevitLookup/Views/Pages/SnoopViewBase.xaml.cs index 47a348d9d..5f0be92ca 100644 --- a/RevitLookup/Views/Pages/SnoopViewBase.xaml.cs +++ b/RevitLookup/Views/Pages/SnoopViewBase.xaml.cs @@ -269,7 +269,14 @@ private void CreateGridContextMenu(DataGrid dataGrid) contextMenu.AddSeparator(); contextMenu.AddLabel("Show"); - + + contextMenu.AddMenuItem("CheckableMenuItem") + .SetHeader("Object members") + .SetCommand(_settingsService.IsObjectMembersAllowed, parameter => + { + _settingsService.IsObjectMembersAllowed = !parameter; + return GetRefreshGridTask(); + }); contextMenu.AddMenuItem("CheckableMenuItem") .SetHeader("Events") .SetCommand(_settingsService.IsEventsAllowed, parameter => From 793a66d2a87dc2ef35748455cbfaf8186a2ab153 Mon Sep 17 00:00:00 2001 From: SergeyNefyodov Date: Tue, 28 Nov 2023 16:30:45 +0400 Subject: [PATCH 2/4] Object members support added --- .../Core/Metadata/DescriptorBuilder.Build.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/RevitLookup/Core/Metadata/DescriptorBuilder.Build.cs b/RevitLookup/Core/Metadata/DescriptorBuilder.Build.cs index 91f20576b..618401eed 100644 --- a/RevitLookup/Core/Metadata/DescriptorBuilder.Build.cs +++ b/RevitLookup/Core/Metadata/DescriptorBuilder.Build.cs @@ -29,13 +29,18 @@ public sealed partial class DescriptorBuilder private IReadOnlyCollection BuildInstanceObject(Type type) { var types = new List(); - while (type.BaseType is not null) + while (type is not null) { - types.Add(type); - type = type.BaseType; + if (type.BaseType is not null) + { + types.Add(type); + } + else if (_settings.IsObjectMembersAllowed) + { + types.Add(type); + } + type = type?.BaseType; } - if (_settings.IsObjectMembersAllowed) - types.Add(typeof(object)); for (var i = types.Count - 1; i >= 0; i--) { From 90a6c3bac4420f8898da37d41340d87797fde369 Mon Sep 17 00:00:00 2001 From: SergeyNefyodov Date: Tue, 28 Nov 2023 17:01:57 +0400 Subject: [PATCH 3/4] Object members support added --- RevitLookup/Core/Metadata/DescriptorBuilder.Build.cs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/RevitLookup/Core/Metadata/DescriptorBuilder.Build.cs b/RevitLookup/Core/Metadata/DescriptorBuilder.Build.cs index 618401eed..69e223e66 100644 --- a/RevitLookup/Core/Metadata/DescriptorBuilder.Build.cs +++ b/RevitLookup/Core/Metadata/DescriptorBuilder.Build.cs @@ -29,19 +29,16 @@ public sealed partial class DescriptorBuilder private IReadOnlyCollection BuildInstanceObject(Type type) { var types = new List(); - while (type is not null) + while (type != null) { - if (type.BaseType is not null) + if (type.BaseType != null || _settings.IsObjectMembersAllowed) { types.Add(type); } - else if (_settings.IsObjectMembersAllowed) - { - types.Add(type); - } - type = type?.BaseType; + type = type.BaseType; } + for (var i = types.Count - 1; i >= 0; i--) { _type = types[i]; From d6212775f08159580a894dc189c4d67ec240a61e Mon Sep 17 00:00:00 2001 From: SergeyNefyodov Date: Tue, 28 Nov 2023 18:23:56 +0400 Subject: [PATCH 4/4] Object members support added --- RevitLookup/Core/Metadata/DescriptorBuilder.Build.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/RevitLookup/Core/Metadata/DescriptorBuilder.Build.cs b/RevitLookup/Core/Metadata/DescriptorBuilder.Build.cs index 69e223e66..3a40ad0a7 100644 --- a/RevitLookup/Core/Metadata/DescriptorBuilder.Build.cs +++ b/RevitLookup/Core/Metadata/DescriptorBuilder.Build.cs @@ -29,16 +29,12 @@ public sealed partial class DescriptorBuilder private IReadOnlyCollection BuildInstanceObject(Type type) { var types = new List(); - while (type != null) + while (_settings.IsObjectMembersAllowed ? type is not null : type!.BaseType is not null) { - if (type.BaseType != null || _settings.IsObjectMembersAllowed) - { - types.Add(type); - } + types.Add(type); type = type.BaseType; } - for (var i = types.Count - 1; i >= 0; i--) { _type = types[i];