//------------------------------------------------------------------------------ // // // [....] // Copyright (c) Microsoft Corporation. All rights reserved. // //------------------------------------------------------------------------------ namespace System.CodeDom { using System.Diagnostics; using System; using Microsoft.Win32; using System.Collections; using System.Runtime.InteropServices; using System.Runtime.Serialization; /// /// /// Represents a single custom attribute. /// /// [ ClassInterface(ClassInterfaceType.AutoDispatch), ComVisible(true), Serializable, ] public class CodeAttributeDeclaration { private string name; private CodeAttributeArgumentCollection arguments = new CodeAttributeArgumentCollection(); [OptionalField] private CodeTypeReference attributeType; /// /// /// Initializes a new instance of . /// /// public CodeAttributeDeclaration() { } /// /// /// Initializes a new instance of using the specified name. /// /// public CodeAttributeDeclaration(string name) { Name = name; } /// /// /// Initializes a new instance of using the specified /// arguments. /// /// public CodeAttributeDeclaration(string name, params CodeAttributeArgument[] arguments) { Name = name; Arguments.AddRange(arguments); } public CodeAttributeDeclaration(CodeTypeReference attributeType) : this ( attributeType, null) { } public CodeAttributeDeclaration(CodeTypeReference attributeType, params CodeAttributeArgument[] arguments) { this.attributeType = attributeType; if( attributeType != null) { this.name = attributeType.BaseType; } if(arguments != null) { Arguments.AddRange(arguments); } } /// /// /// The name of the attribute being declared. /// /// public string Name { get { return (name == null) ? string.Empty : name; } set { name = value; attributeType = new CodeTypeReference(name); } } /// /// /// The arguments for the attribute. /// /// public CodeAttributeArgumentCollection Arguments { get { return arguments; } } public CodeTypeReference AttributeType { get { return attributeType; } } } }