CodeAttributeDeclaration.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / CompMod / System / CodeDOM / CodeAttributeDeclaration.cs / 1305376 / CodeAttributeDeclaration.cs

                            //------------------------------------------------------------------------------ 
// 
//
// [....]
//     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; 
            }
        } 
    } 
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------ 
// 
//
// [....]
//     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; 
            }
        } 
    } 
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.

                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK