diff options
author | Lluis Sanchez <lluis@xamarin.com> | 2017-01-18 14:41:21 +0300 |
---|---|---|
committer | Lluis Sanchez <lluis@xamarin.com> | 2017-01-18 14:41:21 +0300 |
commit | 1919a2edc2cd4d85120062fec3b4b5f55cf6773e (patch) | |
tree | 8a74674ad63b8aa12237985ebef3959d74cc2d05 /Mono.Addins/Mono.Addins.Description/AddinDescription.cs | |
parent | 68e6907602f0dadbf9ce6b2806c71ed2847bfa98 (diff) |
Allow referencing properties inside manifests
Inside an XML manifest it is now possible to reference a property
defined in the add-in header using the syntax $(Name).
For example, $(Version) will be replaced by the version number of
the add-in.
Diffstat (limited to 'Mono.Addins/Mono.Addins.Description/AddinDescription.cs')
-rw-r--r-- | Mono.Addins/Mono.Addins.Description/AddinDescription.cs | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/Mono.Addins/Mono.Addins.Description/AddinDescription.cs b/Mono.Addins/Mono.Addins.Description/AddinDescription.cs index 724204f..bc0e508 100644 --- a/Mono.Addins/Mono.Addins.Description/AddinDescription.cs +++ b/Mono.Addins/Mono.Addins.Description/AddinDescription.cs @@ -698,6 +698,28 @@ namespace Mono.Addins.Description if (val != null) flags = (AddinFlags) Enum.Parse (typeof(AddinFlags), val); } + + bool TryGetVariableValue (string name, out string value) + { + if (variables != null && variables.TryGetValue (name, out value)) + return true; + + switch (name) { + case "Id": value = id; return true; + case "Namespace": value = ns; return true; + case "Version": value = version; return true; + case "CompatVersion": value = compatVersion; return true; + case "DefaultEnabled": value = defaultEnabled.ToString (); return true; + case "IsRoot": value = isroot.ToString (); return true; + case "Flags": value = flags.ToString (); return true; + } + if (properties != null && properties.HasProperty (name)) { + value = properties.GetPropertyValue (name); + return true; + } + value = null; + return false; + } /// <summary> /// Saves the add-in description. @@ -1002,7 +1024,7 @@ namespace Mono.Addins.Description internal string ParseString (string input) { - if (input == null || input.Length < 4 || variables == null || variables.Count == 0) + if (input == null || input.Length < 4) return input; int i = input.IndexOf ("$("); @@ -1029,7 +1051,7 @@ namespace Mono.Addins.Description string tag = input.Substring (start, i - start); string tagValue; - if (variables.TryGetValue (tag, out tagValue)) + if (TryGetVariableValue (tag, out tagValue)) result.Append (tagValue); else { result.Append ('$'); |