<Type Name="NodeAttributeAttribute" FullName="Mono.Addins.NodeAttributeAttribute">
  <TypeSignature Language="C#" Value="public class NodeAttributeAttribute : Attribute" />
  <AssemblyInfo>
    <AssemblyName>Mono.Addins</AssemblyName>
    <AssemblyVersion>1.0.0.0</AssemblyVersion>
  </AssemblyInfo>
  <Base>
    <BaseTypeName>System.Attribute</BaseTypeName>
  </Base>
  <Interfaces />
  <Members>
    <Member MemberName=".ctor">
      <MemberSignature Language="C#" Value="public NodeAttributeAttribute ();" />
      <MemberType>Constructor</MemberType>
      <Parameters />
      <Docs>
        <summary>Initializes a new instance.</summary>
        <remarks>It takes the field name and type as name and type of the attribute.</remarks>
      </Docs>
    </Member>
    <Member MemberName=".ctor">
      <MemberSignature Language="C#" Value="public NodeAttributeAttribute (string name);" />
      <MemberType>Constructor</MemberType>
      <Parameters>
        <Parameter Name="name" Type="System.String" />
      </Parameters>
      <Docs>
        <param name="name">XML name of the attribute.</param>
        <summary>Initializes a new instance.</summary>
        <remarks />
      </Docs>
    </Member>
    <Member MemberName=".ctor">
      <MemberSignature Language="C#" Value="public NodeAttributeAttribute (string name, bool required);" />
      <MemberType>Constructor</MemberType>
      <Parameters>
        <Parameter Name="name" Type="System.String" />
        <Parameter Name="required" Type="System.Boolean" />
      </Parameters>
      <Docs>
        <param name="name">XML name of the attribute.</param>
        <param name="required">Indicates whether the attribute is required or not.</param>
        <summary>Initializes a new instance.</summary>
        <remarks />
      </Docs>
    </Member>
    <Member MemberName="Name">
      <MemberSignature Language="C#" Value="public string Name { set; get; };" />
      <MemberType>Property</MemberType>
      <ReturnValue>
        <ReturnType>System.String</ReturnType>
      </ReturnValue>
      <Docs>
        <summary>XML name of the attribute.</summary>
        <value>XML name of the attribute.</value>
        <remarks>
          <para>
If the name is not specified, the field name to which the [NodeAttribute] is applied will be used as name.
</para>
          <para>
Providing a name is mandatory when applying [NodeAttribute] at class level.
</para>
        </remarks>
      </Docs>
    </Member>
    <Member MemberName="Required">
      <MemberSignature Language="C#" Value="public bool Required { set; get; };" />
      <MemberType>Property</MemberType>
      <ReturnValue>
        <ReturnType>System.Boolean</ReturnType>
      </ReturnValue>
      <Docs>
        <summary>Indicates whether the attribute is required or not.</summary>
        <value>'true' if the attribute is required.</value>
        <remarks />
      </Docs>
    </Member>
    <Member MemberName=".ctor">
      <MemberSignature Language="C#" Value="public NodeAttributeAttribute (string name, Type type);" />
      <MemberType>Constructor</MemberType>
      <Parameters>
        <Parameter Name="name" Type="System.String" />
        <Parameter Name="type" Type="System.Type" />
      </Parameters>
      <Docs>
        <param name="name">XML name of the attribute.</param>
        <param name="type">Type of the extension node attribute.</param>
        <summary>Initializes a new instance.</summary>
        <remarks>This constructor can only be used when applying [NodeAttribute] at class level.</remarks>
      </Docs>
    </Member>
    <Member MemberName=".ctor">
      <MemberSignature Language="C#" Value="public NodeAttributeAttribute (string name, Type type, bool required);" />
      <MemberType>Constructor</MemberType>
      <Parameters>
        <Parameter Name="name" Type="System.String" />
        <Parameter Name="type" Type="System.Type" />
        <Parameter Name="required" Type="System.Boolean" />
      </Parameters>
      <Docs>
        <param name="name">XML name of the attribute.</param>
        <param name="type">Type of the extension node attribute.</param>
        <param name="required">Indicates whether the attribute is required or not.</param>
        <summary>Initializes a new instance.</summary>
        <remarks>This constructor can only be used when applying [NodeAttribute] at class level.</remarks>
      </Docs>
    </Member>
    <Member MemberName="Description">
      <MemberSignature Language="C#" Value="public string Description { set; get; };" />
      <MemberType>Property</MemberType>
      <ReturnValue>
        <ReturnType>System.String</ReturnType>
      </ReturnValue>
      <Docs>
        <summary>Description of the attribute.</summary>
        <value>Description of the attribute.</value>
        <remarks>To be used in the extension point documentation.</remarks>
      </Docs>
    </Member>
    <Member MemberName="Type">
      <MemberSignature Language="C#" Value="public Type Type { set; get; };" />
      <MemberType>Property</MemberType>
      <ReturnValue>
        <ReturnType>System.Type</ReturnType>
      </ReturnValue>
      <Docs>
        <summary>Type of the extension node attribute.</summary>
        <value>A type.</value>
        <remarks>To be used only when applying [NodeAttribute] at class level. Not required when it is applied to a field, since the attribute type will be the type of the field.</remarks>
      </Docs>
    </Member>
  </Members>
  <Docs>
    <summary>Indicates that a field is bound to a node attribute</summary>
    <remarks>
      <para>The [NodeAttribute] custom attribute can be used to specify fields that have to be initialized from node attributes. By default, a field is will get its value from an attribute with the same name, although it is possible to specify a different name by setting the NodeAttribute.Name property. NodeAttribute also has a Required property for specifying if an attribute is mandatory or not.
</para>
      <example>
        <code lang="C#">
public class FileTemplateNode: ExtensionNode
{
	// Will match elements like &lt;FileTemplate resource-name="blah" /&gt;
	// The true parameter specifies that the attribute is required
	[NodeAttribute ("resource-name", true, Description="Name of the resource where the template is stored.")]
	string resource;
	
	[NodeAttribute]
	string name;
	
	public string Name {
		get { return name != null ? name : Id; }
	}
		
	public virtual string GetContent ()
	{
		using (StreamReader sr = new StreamReader(Addin.GetResource (resource))) {
			return sr.ReadToEnd (); 
		}
	}
	
}  </code>
      </example>
      <para>
If an <see cref="T:Mono.Addins.ExtensionNode" /> subclass overrides the <see cref="M:Mono.Addins.ExtensionNode.Read" /> method to provide a custom node deserialization implementation, [NodeAttribute] attributes applied to fileds will be ignored. In this case, this attribute can also be applied at class level to provide documentation about the supported attributes. For example:
</para>
      <example>
        <code lang="C#">
[NodeAttribute ("name", typeof(string), false, Description="Name of the template.")]
[NodeAttribute ("resource-name", typeof(string), true, Description="Name of the resource where the template is stored.")]
public class FileTemplateNode: ExtensionNode
{
	string resource;
	string name;
	
	public string Name {
		get { return name != null ? name : Id; }
	}

	public virtual string GetContent ()
	{
		using (StreamReader sr = new StreamReader(Addin.GetResource (resource))) {
			return sr.ReadToEnd (); 
		}
	}

	protected override void Read (NodeElement elem)
	{
		resource = elem.GetAttribute ("resource-name");
		name = elem.GetAttribute ("name");
	}
}
  </code>
      </example>
    </remarks>
  </Docs>
  <Attributes>
    <Attribute>
      <AttributeName>System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Field, AllowMultiple=true)</AttributeName>
    </Attribute>
  </Attributes>
</Type>