diff options
author | Mikayla Hutchinson <m.j.hutchinson@gmail.com> | 2017-05-02 05:31:11 +0300 |
---|---|---|
committer | Mikayla Hutchinson <m.j.hutchinson@gmail.com> | 2017-05-02 19:05:36 +0300 |
commit | 79401b1233b98fed842891a0e518e47351f883bf (patch) | |
tree | 38dcdb3e50d0c2bac2f21c859e841dd9bf51f552 /Mono.Addins/Mono.Addins.Database | |
parent | 4f77823a0f3cce3989f79fbc1bf962c81dc485bc (diff) |
Fix issue where conditions were treated as extensions
Diffstat (limited to 'Mono.Addins/Mono.Addins.Database')
-rw-r--r-- | Mono.Addins/Mono.Addins.Database/AddinUpdateData.cs | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/Mono.Addins/Mono.Addins.Database/AddinUpdateData.cs b/Mono.Addins/Mono.Addins.Database/AddinUpdateData.cs index 5c4ab48..cbae4d4 100644 --- a/Mono.Addins/Mono.Addins.Database/AddinUpdateData.cs +++ b/Mono.Addins/Mono.Addins.Database/AddinUpdateData.cs @@ -31,6 +31,7 @@ using System; using System.Collections; using Mono.Addins.Description; using System.Collections.Generic; +using System.Linq; namespace Mono.Addins.Database { @@ -163,7 +164,7 @@ namespace Mono.Addins.Database if (!found) monitor.ReportWarning ("The add-in '" + description.AddinId + "' is trying to register the class '" + extension.Path.Substring (1) + "', but there isn't any add-in defining a suitable extension point"); } - else if (extension.Path.StartsWith ("%")) { + else if (extension.Path.StartsWith ("%", StringComparison.Ordinal)) { string[] objectTypes = extension.Path.Substring (1).Split (','); bool found = false; foreach (string s in objectTypes) { @@ -174,8 +175,9 @@ namespace Mono.Addins.Database ExtensionPoint ep = (ExtensionPoint) ((ExtensionNodeSet)nt.Parent).Parent; if (IsAddinCompatible (ep.ParentAddinDescription, description, module)) { extension.Path = ep.Path; - foreach (ExtensionNodeDescription node in extension.ExtensionNodes) + foreach (ExtensionNodeDescription node in GetNodesIgnoringConditions (extension)) { node.NodeName = nt.NodeName; + } RegisterExtension (description, module, ep.Path); } } @@ -185,6 +187,25 @@ namespace Mono.Addins.Database monitor.ReportWarning ("The add-in '" + description.AddinId + "' is trying to register the class '" + extension.Path.Substring (1) + "', but there isn't any add-in defining a suitable extension point"); } } + + static IEnumerable<ExtensionNodeDescription> GetNodesIgnoringConditions (Extension extension) + { + foreach (ExtensionNodeDescription node in extension.ExtensionNodes) { + if (node.IsCondition) { + //first node in a complex condition is the actual condition + bool skipFirst = node.NodeName == "ComplexCondition"; + foreach (ExtensionNodeDescription child in node.ChildNodes) { + if (skipFirst) { + skipFirst = false; + continue; + } + yield return child; + } + } else { + yield return node; + } + } + } public void RegisterExtension (AddinDescription description, ModuleDescription module, string path) { |