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@novell.com>2010-05-21 14:38:40 +0400
committerLluis Sanchez <lluis@novell.com>2010-05-21 14:38:40 +0400
commitf7f30141351477f14b3e3f25c4ce92e4ea0d5033 (patch)
treedd8820e50c9d22c7a5218048582965fc8fedcbed /Mono.Addins
parentf1183df2745fd63a144c8905af762da7f59a4501 (diff)
parentdbb5c3ab0c608d00c499ae69194180e81745c855 (diff)
* Test/UnitTests/IWriter.cs:
* Test/UnitTests/Makefile.am: * Test/UnitTests/TestEvents.cs: * Test/UnitTests/ExtensionModel: * Test/UnitTests/ComplexNode.cs: * Test/UnitTests/UnitTests.csproj: * Test/UnitTests/TestExtensions.cs: * Test/UnitTests/ISampleExtender.cs: * Test/UnitTests/NodeWithAttribute.cs: * Test/UnitTests/GlobalInfoCondition.cs: * Test/UnitTests/IWriterWithMetadata.cs: * Test/UnitTests/ParameterInfoCondition.cs: * Test/UnitTests/ExtensionModel/IWriter.cs: * Test/UnitTests/ExtensionModel/ComplexNode.cs: * Test/HelloWorldExtension/AttributeExtensions.cs: * Test/UnitTests/ExtensionModel/ISampleExtender.cs: * Test/UnitTests/ExtensionModel/NodeWithAttribute.cs: * Test/UnitTests/ExtensionModel/IWriterWithMetadata.cs: * Test/UnitTests/ExtensionModel/GlobalInfoCondition.cs: * Test/UnitTests/ExtensionModel/ParameterInfoCondition.cs: * Test/UnitTests/ExtensionModel/SimpleExtensionAttribute.cs: Reorganized tests. * Mono.Addins/Mono.Addins/ExtensionNode.cs: * Mono.Addins/Mono.Addins/ExtensionTree.cs: Data extension points bound to an attribute now generate nodes of type ExtensionNode<TheAttribute> * Mono.Addins/Mono.Addins/Addin.cs: Added some docs. * Mono.Addins/Mono.Addins.Database/AddinScanner.cs: * Mono.Addins/Mono.Addins/ExtensionNodeAttribute.cs: * Mono.Addins/Mono.Addins.Database/AddinUpdateData.cs: * Mono.Addins/Mono.Addins.Description/ExtensionNodeType.cs: Changed name of property (for consistency) * Mono.Addins/Mono.Addins/ExtensionPointAttribute.cs: Don't set a default node name. The default name is assigned while scanning. * Mono.Addins/Mono.Addins.Database/DefaultAssemblyReflector.cs: This class should not be public. svn path=/trunk/mono-addins/; revision=157675
Diffstat (limited to 'Mono.Addins')
-rw-r--r--Mono.Addins/ChangeLog21
-rw-r--r--Mono.Addins/Mono.Addins.Database/AddinScanner.cs8
-rw-r--r--Mono.Addins/Mono.Addins.Database/AddinUpdateData.cs6
-rw-r--r--Mono.Addins/Mono.Addins.Database/DefaultAssemblyReflector.cs4
-rw-r--r--Mono.Addins/Mono.Addins.Description/ExtensionNodeType.cs31
-rw-r--r--Mono.Addins/Mono.Addins/Addin.cs47
-rw-r--r--Mono.Addins/Mono.Addins/ExtensionNode.cs12
-rw-r--r--Mono.Addins/Mono.Addins/ExtensionNodeAttribute.cs4
-rw-r--r--Mono.Addins/Mono.Addins/ExtensionPointAttribute.cs2
-rw-r--r--Mono.Addins/Mono.Addins/ExtensionTree.cs17
10 files changed, 122 insertions, 30 deletions
diff --git a/Mono.Addins/ChangeLog b/Mono.Addins/ChangeLog
index 119c163..1e76484 100644
--- a/Mono.Addins/ChangeLog
+++ b/Mono.Addins/ChangeLog
@@ -1,3 +1,24 @@
+2010-05-21 Lluis Sanchez Gual <lluis@novell.com>
+
+ * Mono.Addins/ExtensionNode.cs:
+ * Mono.Addins/ExtensionTree.cs: Data extension points bound to
+ an attribute now generate nodes of type
+ ExtensionNode<TheAttribute>
+
+ * Mono.Addins/Addin.cs: Added some docs.
+
+ * Mono.Addins.Database/AddinScanner.cs:
+ * Mono.Addins/ExtensionNodeAttribute.cs:
+ * Mono.Addins.Database/AddinUpdateData.cs:
+ * Mono.Addins.Description/ExtensionNodeType.cs: Changed name
+ of property (for consistency)
+
+ * Mono.Addins/ExtensionPointAttribute.cs: Don't set a default
+ node name. The default name is assigned while scanning.
+
+ * Mono.Addins.Database/DefaultAssemblyReflector.cs: This class
+ should not be public.
+
2010-05-20 Lluis Sanchez Gual <lluis@novell.com>
* Makefile.am:
diff --git a/Mono.Addins/Mono.Addins.Database/AddinScanner.cs b/Mono.Addins/Mono.Addins.Database/AddinScanner.cs
index 9164ec1..a66f398 100644
--- a/Mono.Addins/Mono.Addins.Database/AddinScanner.cs
+++ b/Mono.Addins/Mono.Addins.Database/AddinScanner.cs
@@ -821,7 +821,7 @@ namespace Mono.Addins.Database
ep.Description = ext.Description;
ep.Name = ext.Name;
ExtensionNodeType nt = ep.AddExtensionNode (ext.NodeName, ext.NodeTypeName);
- nt.CustomAttributeTypeName = ext.ExtensionAttributeTypeName;
+ nt.ExtensionAttributeTypeName = ext.ExtensionAttributeTypeName;
}
}
@@ -917,7 +917,7 @@ namespace Mono.Addins.Database
}
nt.Id = epa.NodeName;
nt.TypeName = epa.NodeType.FullName;
- nt.CustomAttributeTypeName = epa.ExtensionAttributeTypeName;
+ nt.ExtensionAttributeTypeName = epa.ExtensionAttributeTypeName;
ep.NodeSet.NodeTypes.Add (nt);
ep.Description = epa.Description;
ep.Name = epa.Name;
@@ -959,8 +959,8 @@ namespace Mono.Addins.Database
nt.Id = nodeAtt.NodeName;
if (nt.Description.Length == 0 && nodeAtt.Description.Length > 0)
nt.Description = nodeAtt.Description;
- if (nt.CustomAttributeTypeName.Length == 0 && nodeAtt.CustomAttributeTypeName.Length > 0)
- nt.CustomAttributeTypeName = nodeAtt.CustomAttributeTypeName;
+ if (nt.ExtensionAttributeTypeName.Length == 0 && nodeAtt.ExtensionAttributeTypeName.Length > 0)
+ nt.ExtensionAttributeTypeName = nodeAtt.ExtensionAttributeTypeName;
} else {
// Use the node type name as default name
if (nt.Id.Length == 0)
diff --git a/Mono.Addins/Mono.Addins.Database/AddinUpdateData.cs b/Mono.Addins/Mono.Addins.Database/AddinUpdateData.cs
index 20b674c..ce4272d 100644
--- a/Mono.Addins/Mono.Addins.Database/AddinUpdateData.cs
+++ b/Mono.Addins/Mono.Addins.Database/AddinUpdateData.cs
@@ -132,11 +132,11 @@ namespace Mono.Addins.Database
}
list.Add (ep);
}
- if (nt.CustomAttributeTypeName.Length > 0) {
+ if (nt.ExtensionAttributeTypeName.Length > 0) {
List<ExtensionNodeType> list;
- if (!customAttributeTypeExtensions.TryGetValue (nt.CustomAttributeTypeName, out list)) {
+ if (!customAttributeTypeExtensions.TryGetValue (nt.ExtensionAttributeTypeName, out list)) {
list = new List<ExtensionNodeType> ();
- customAttributeTypeExtensions [nt.CustomAttributeTypeName] = list;
+ customAttributeTypeExtensions [nt.ExtensionAttributeTypeName] = list;
}
list.Add (nt);
}
diff --git a/Mono.Addins/Mono.Addins.Database/DefaultAssemblyReflector.cs b/Mono.Addins/Mono.Addins.Database/DefaultAssemblyReflector.cs
index 9cf7bfe..b835f8a 100644
--- a/Mono.Addins/Mono.Addins.Database/DefaultAssemblyReflector.cs
+++ b/Mono.Addins/Mono.Addins.Database/DefaultAssemblyReflector.cs
@@ -32,9 +32,7 @@ using System.Collections.Generic;
namespace Mono.Addins.Database
{
-
-
- public class DefaultAssemblyReflector: IAssemblyReflector
+ class DefaultAssemblyReflector: IAssemblyReflector
{
public void Initialize (IAssemblyLocator locator)
{
diff --git a/Mono.Addins/Mono.Addins.Description/ExtensionNodeType.cs b/Mono.Addins/Mono.Addins.Description/ExtensionNodeType.cs
index 7a886b6..3fb48e9 100644
--- a/Mono.Addins/Mono.Addins.Description/ExtensionNodeType.cs
+++ b/Mono.Addins/Mono.Addins.Description/ExtensionNodeType.cs
@@ -37,6 +37,9 @@ using Mono.Addins.Serialization;
namespace Mono.Addins.Description
{
+ /// <summary>
+ /// An extension node type definition.
+ /// </summary>
public sealed class ExtensionNodeType: ExtensionNodeSet
{
string typeName;
@@ -87,35 +90,49 @@ namespace Mono.Addins.Description
set { addinId = value; }
}
- // Type of the extension node
+ /// <summary>
+ /// Type of the extension node.
+ /// </summary>
public string TypeName {
get { return typeName != null ? typeName : string.Empty; }
set { typeName = value; }
}
+ /// <summary>
+ /// Element name to be used when defining an extension in an XML manifest. The default name is "Type".
+ /// </summary>
public string NodeName {
get { return Id; }
set { Id = value; }
}
- // Type of the object that the extension creates (only valid for TypeNodeExtension).
+ /// <summary>
+ /// Type of the object that the extension creates (only valid for TypeNodeExtension).
+ /// </summary>
public string ObjectTypeName {
get { return objectTypeName != null ? objectTypeName : string.Empty; }
set { objectTypeName = value; }
}
- // Name of the custom attribute that can be used to declare nodes of this type
- public string CustomAttributeTypeName {
+ /// <summary>
+ /// Name of the custom attribute that can be used to declare nodes of this type
+ /// </summary>
+ public string ExtensionAttributeTypeName {
get { return customAttributeTypeName ?? string.Empty; }
set { customAttributeTypeName = value; }
}
- // The description
+ /// <summary>
+ /// Long description of the node type
+ /// </summary>
public string Description {
get { return description != null ? description : string.Empty; }
set { description = value; }
}
+ /// <summary>
+ /// Attributes supported by the extension node type.
+ /// </summary>
public NodeTypeAttributeCollection Attributes {
get {
if (attributes == null) {
@@ -205,8 +222,8 @@ namespace Mono.Addins.Description
else
Element.RemoveAttribute ("objectType");
- if (CustomAttributeTypeName.Length > 0)
- Element.SetAttribute ("customAttributeType", CustomAttributeTypeName);
+ if (ExtensionAttributeTypeName.Length > 0)
+ Element.SetAttribute ("customAttributeType", ExtensionAttributeTypeName);
else
Element.RemoveAttribute ("customAttributeType");
diff --git a/Mono.Addins/Mono.Addins/Addin.cs b/Mono.Addins/Mono.Addins/Addin.cs
index 47c62e1..d11c30d 100644
--- a/Mono.Addins/Mono.Addins/Addin.cs
+++ b/Mono.Addins/Mono.Addins/Addin.cs
@@ -37,6 +37,9 @@ using Mono.Addins.Database;
namespace Mono.Addins
{
+ /// <summary>
+ /// An add-in.
+ /// </summary>
public class Addin
{
AddinInfo addin;
@@ -51,6 +54,9 @@ namespace Mono.Addins
configFile = file;
}
+ /// <summary>
+ /// Full identifier of the add-in, including namespace and version.
+ /// </summary>
public string Id {
get {
if (configFile != null)
@@ -59,14 +65,23 @@ namespace Mono.Addins
}
}
+ /// <summary>
+ /// Namespace of the add-in.
+ /// </summary>
public string Namespace {
get { return this.AddinInfo.Namespace; }
}
+ /// <summary>
+ /// Identifier of the add-in (without namespace)
+ /// </summary>
public string LocalId {
get { return this.AddinInfo.LocalId; }
}
+ /// <summary>
+ /// Version of the add-in
+ /// </summary>
public string Version {
get { return this.AddinInfo.Version; }
}
@@ -79,6 +94,18 @@ namespace Mono.Addins
get { return Path.Combine (database.AddinPrivateDataPath, Path.GetFileNameWithoutExtension (Description.FileName)); }
}
+ /// <summary>
+ /// Checks version compatibility.
+ /// </summary>
+ /// <param name="version">
+ /// An add-in version.
+ /// </param>
+ /// <returns>
+ /// True if the provided version is compatible with this add-in.
+ /// </returns>
+ /// <remarks>
+ /// This method checks the CompatVersion property to know if the provided version is compatible with the version of this add-in.
+ /// </remarks>
public bool SupportsVersion (string version)
{
return AddinInfo.SupportsVersion (version);
@@ -102,6 +129,17 @@ namespace Mono.Addins
}
}
+ /// <summary>
+ /// Gets or sets the enabled status of the add-in.
+ /// </summary>
+ /// <remarks>
+ /// This property can be used to enable or disable an add-in.
+ /// The enabled status of an add-in is stored in the add-in registry,
+ /// so when an add-in is disabled, it will be disabled for all applications
+ /// sharing the same registry.
+ /// When an add-in is enabled or disabled, the extension points currently loaded
+ /// in memory will be properly updated to include or exclude extensions from the add-in.
+ /// </remarks>
public bool Enabled {
get { return AddinInfo.IsRoot ? true : database.IsAddinEnabled (Description.Domain, AddinInfo.Id, true); }
set {
@@ -112,10 +150,16 @@ namespace Mono.Addins
}
}
+ /// <summary>
+ /// Returns 'true' if the add-in is installed in the user's personal folder
+ /// </summary>
public bool IsUserAddin {
get { return configFile.StartsWith (Environment.GetFolderPath (Environment.SpecialFolder.Personal)); }
}
+ /// <summary>
+ /// Path to the add-in file (it can be an assembly or a standalone XML manifest)
+ /// </summary>
public string AddinFile {
get {
if (sourceFile == null && addin == null)
@@ -137,6 +181,9 @@ namespace Mono.Addins
}
}
+ /// <summary>
+ /// Description of the add-in
+ /// </summary>
public AddinDescription Description {
get {
if (desc != null) {
diff --git a/Mono.Addins/Mono.Addins/ExtensionNode.cs b/Mono.Addins/Mono.Addins/ExtensionNode.cs
index 39b93a9..a51fb2f 100644
--- a/Mono.Addins/Mono.Addins/ExtensionNode.cs
+++ b/Mono.Addins/Mono.Addins/ExtensionNode.cs
@@ -352,8 +352,14 @@ namespace Mono.Addins
}
}
-/* public class ExtensionNode<T>: ExtensionNode where T:CustomExtensionAttribute
+ public class ExtensionNode<T>: ExtensionNode where T:CustomExtensionAttribute
{
- public T Data { get; internal set; }
- }*/
+ T data;
+
+ [NodeAttribute]
+ public T Data {
+ get { return data; }
+ internal set { data = value; }
+ }
+ }
}
diff --git a/Mono.Addins/Mono.Addins/ExtensionNodeAttribute.cs b/Mono.Addins/Mono.Addins/ExtensionNodeAttribute.cs
index eb24376..bf089a3 100644
--- a/Mono.Addins/Mono.Addins/ExtensionNodeAttribute.cs
+++ b/Mono.Addins/Mono.Addins/ExtensionNodeAttribute.cs
@@ -64,12 +64,12 @@ namespace Mono.Addins
set { description = value; }
}
- public Type CustomAttributeType {
+ public Type ExtensionAttributeType {
get { return customAttributeType; }
set { customAttributeType = value; customAttributeTypeName = value.FullName; }
}
- internal string CustomAttributeTypeName {
+ internal string ExtensionAttributeTypeName {
get { return customAttributeTypeName ?? string.Empty; }
set { customAttributeTypeName = value; }
}
diff --git a/Mono.Addins/Mono.Addins/ExtensionPointAttribute.cs b/Mono.Addins/Mono.Addins/ExtensionPointAttribute.cs
index 215548f..a4bd4b5 100644
--- a/Mono.Addins/Mono.Addins/ExtensionPointAttribute.cs
+++ b/Mono.Addins/Mono.Addins/ExtensionPointAttribute.cs
@@ -98,7 +98,7 @@ namespace Mono.Addins
}
public string NodeName {
- get { return nodeName != null && nodeName.Length > 0 ? nodeName : "Type"; }
+ get { return nodeName != null && nodeName.Length > 0 ? nodeName : string.Empty; }
set { nodeName = value; }
}
diff --git a/Mono.Addins/Mono.Addins/ExtensionTree.cs b/Mono.Addins/Mono.Addins/ExtensionTree.cs
index 4bf0c34..45a2ecf 100644
--- a/Mono.Addins/Mono.Addins/ExtensionTree.cs
+++ b/Mono.Addins/Mono.Addins/ExtensionTree.cs
@@ -206,13 +206,16 @@ namespace Mono.Addins
// If no type name is provided, use TypeExtensionNode by default
if (ntype.TypeName == null || ntype.TypeName.Length == 0 || ntype.TypeName == typeof(TypeExtensionNode).FullName) {
// If it has a custom attribute, use the generic version of TypeExtensionNode
- if (ntype.CustomAttributeTypeName.Length > 0) {
- Type attType = p.GetType (ntype.CustomAttributeTypeName, false);
+ if (ntype.ExtensionAttributeTypeName.Length > 0) {
+ Type attType = p.GetType (ntype.ExtensionAttributeTypeName, false);
if (attType == null) {
- addinEngine.ReportError ("Custom attribute type '" + ntype.CustomAttributeTypeName + "' not found.", ntype.AddinId, null, false);
+ addinEngine.ReportError ("Custom attribute type '" + ntype.ExtensionAttributeTypeName + "' not found.", ntype.AddinId, null, false);
return false;
}
- ntype.Type = typeof(TypeExtensionNode<>).MakeGenericType (attType);
+ if (ntype.ObjectTypeName.Length > 0)
+ ntype.Type = typeof(TypeExtensionNode<>).MakeGenericType (attType);
+ else
+ ntype.Type = typeof(ExtensionNode<>).MakeGenericType (attType);
} else {
ntype.Type = typeof(TypeExtensionNode);
return true;
@@ -237,10 +240,10 @@ namespace Mono.Addins
// get the member map for the attribute.
if (boundAttributeType != null) {
- if (ntype.CustomAttributeTypeName.Length == 0)
+ if (ntype.ExtensionAttributeTypeName.Length == 0)
throw new InvalidOperationException ("Extension node not bound to a custom attribute.");
- if (ntype.CustomAttributeTypeName != boundAttributeType.MemberType.FullName)
- throw new InvalidOperationException ("Incorrect custom attribute type declaration in " + ntype.Type + ". Expected '" + ntype.CustomAttributeTypeName + "' found '" + boundAttributeType.MemberType.FullName + "'");
+ if (ntype.ExtensionAttributeTypeName != boundAttributeType.MemberType.FullName)
+ throw new InvalidOperationException ("Incorrect custom attribute type declaration in " + ntype.Type + ". Expected '" + ntype.ExtensionAttributeTypeName + "' found '" + boundAttributeType.MemberType.FullName + "'");
fields = GetMembersMap (boundAttributeType.MemberType, out boundAttributeType);
if (fields.Count > 0)