diff options
author | Rodrigo Moya <rodrigo.moya@xamarin.com> | 2019-06-18 14:59:24 +0300 |
---|---|---|
committer | Rodrigo Moya <rodrigo.moya@xamarin.com> | 2019-07-01 11:31:35 +0300 |
commit | da6ec6c80a3d9bd2fb890d9415d355e199ad9432 (patch) | |
tree | 7fa59b6122498ebe5f7e447c97ec4fc4703170ff /main/src/core/MonoDevelop.Core | |
parent | 83aecbee19cdac80bc616b2fc7b50eb774a69364 (diff) |
[Core] Listen to extension node changes for NestingRulesProvider's
Diffstat (limited to 'main/src/core/MonoDevelop.Core')
-rw-r--r-- | main/src/core/MonoDevelop.Core/MonoDevelop.Projects.FileNesting/FileNestingService.cs | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.FileNesting/FileNestingService.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.FileNesting/FileNestingService.cs index fa3c2707d5..bbfb69d587 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.FileNesting/FileNestingService.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.FileNesting/FileNestingService.cs @@ -25,24 +25,41 @@ // THE SOFTWARE. using System; -using System.Collections.Generic; +using System.Collections.Immutable; +using Mono.Addins; +using MonoDevelop.Core; namespace MonoDevelop.Projects.FileNesting { internal static class FileNestingService { - static List<NestingRulesProvider> rulesProviders; + static ImmutableList<NestingRulesProvider> rulesProviders; static FileNestingService () { + AddinManager.AddExtensionNodeHandler (typeof (NestingRulesProvider), HandleRulesProviderExtension); + } + + static void HandleRulesProviderExtension (object sender, ExtensionNodeEventArgs args) + { + if (rulesProviders != null) { + var pr = args.ExtensionObject as NestingRulesProvider; + if (pr != null) { + if (args.Change == ExtensionChange.Add) { + rulesProviders = rulesProviders.Add (pr); + } else { + rulesProviders = rulesProviders.Remove (pr); + } + } + } } public static string GetParentFile (string inputFile) { if (rulesProviders == null) { - rulesProviders = new List<NestingRulesProvider> (); - foreach (var pr in Mono.Addins.AddinManager.GetExtensionObjects<NestingRulesProvider> ()) { - rulesProviders.Add (pr); + rulesProviders = ImmutableList<NestingRulesProvider>.Empty; + foreach (var pr in AddinManager.GetExtensionObjects<NestingRulesProvider> ()) { + rulesProviders = rulesProviders.Add (pr); } } |