Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono-addins.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLluis Sanchez <lluis@xamarin.com>2017-01-18 14:41:21 +0300
committerLluis Sanchez <lluis@xamarin.com>2017-01-18 14:41:21 +0300
commit1919a2edc2cd4d85120062fec3b4b5f55cf6773e (patch)
tree8a74674ad63b8aa12237985ebef3959d74cc2d05 /Mono.Addins/Mono.Addins.Description
parent68e6907602f0dadbf9ce6b2806c71ed2847bfa98 (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')
-rw-r--r--Mono.Addins/Mono.Addins.Description/AddinDescription.cs26
-rw-r--r--Mono.Addins/Mono.Addins.Description/AddinPropertyCollection.cs10
2 files changed, 33 insertions, 3 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 ('$');
diff --git a/Mono.Addins/Mono.Addins.Description/AddinPropertyCollection.cs b/Mono.Addins/Mono.Addins.Description/AddinPropertyCollection.cs
index 3296b7c..1b35be7 100644
--- a/Mono.Addins/Mono.Addins.Description/AddinPropertyCollection.cs
+++ b/Mono.Addins/Mono.Addins.Description/AddinPropertyCollection.cs
@@ -109,6 +109,14 @@ namespace Mono.Addins.Description
/// Locale of the property
/// </param>
void RemoveProperty (string name, string locale);
+
+
+ /// <summary>
+ /// Checks whether this collection contains a property
+ /// </summary>
+ /// <returns><c>true</c>, if the collection has the property, <c>false</c> otherwise.</returns>
+ /// <param name="name">Name of the property</param>
+ bool HasProperty (string name);
}
class AddinPropertyCollectionImpl: List<AddinProperty>, AddinPropertyCollection
@@ -236,7 +244,7 @@ namespace Mono.Addins.Description
}
}
- internal bool HasProperty (string name)
+ public bool HasProperty (string name)
{
return this.Any (p => p.Name == name);
}