using System;
namespace AnticipatingMinds.Genesis.CodeDOM{
/// <summary>
/// Represents a single attribute specification.
/// </summary>
/// <remarks>
/// <para>
/// Attribute specification is the application of a previously defined attribute to a declaration.
/// An attribute is a piece of additional declarative information that is specified for a declaration.
/// (ECMA 334. Page 311, Line 15)
/// </para>
/// </remarks>
[Serializable()]
public class CodeAttribute : CodeElement
{
/// <summary>
/// Initializes a new instance of the CodeAttribute class.
/// </summary>
public CodeAttribute(): this(string.Empty){}
/// <summary>
/// Initializes a new instance of the CodeAttribute class.
/// </summary>
/// <param name="typeName">The name of the attribute type.</param>
public CodeAttribute(string typeName)
{
type = new CodeTypeReference(typeName);
}
/// <summary>
/// Initializes a new instance of the CodeAttribute class.
/// </summary>
/// <param name="typeName">The name of the attribute type.</param>
/// <param name="arguments">The parameters for the attribute instantiation. </param>
public CodeAttribute(string typeName, params CodeArgument[] arguments)
{
type = new CodeTypeReference(typeName);
Arguments.AddRange(arguments);
}
/// <summary>
/// Gets or sets the attribute type.
/// </summary>
public CodeTypeReference AttributeType
{
get
{
return type;
}
set
{
type = value;
}
}
/// <summary>
/// Atribute scope.
/// </summary>
/// <remarks>Some languages define an attribute scope.
/// Some .NET elements (an assembly or module)
/// allow attributes to be associated with them but do not have a clear source code
/// definition to associate an attribute with it. In order to solveit some language
/// (C#) allow to specify attribute scopy. Such attribute, defined in global namespace,
/// will be associated with an element defined by a scope.
/// See ECMA 334. Page 311, Line 14 for more details.
/// </remarks>
public string Scope
{
get
{
return scope;
}
set
{
scope = (value == null ? string.Empty:value);
}
}
/// <summary>
/// Gets or sets the arguments for attribute instatiation.
/// </summary>
public CodeArgumentCollection Arguments
{
get
{
return arguments;
}
}
private CodeTypeReference type;
private string scope;
private CodeArgumentCollection arguments = new CodeArgumentCollection();
}
}
|