SwitchAttribute.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / CompMod / System / Diagnostics / SwitchAttribute.cs / 1305376 / SwitchAttribute.cs

                            //------------------------------------------------------------------------------ 
// 
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// 
//----------------------------------------------------------------------------- 

using System; 
using System.Reflection; 
using System.Collections;
 
namespace System.Diagnostics {

    [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor |
                    AttributeTargets.Event | AttributeTargets.Method | AttributeTargets.Property)] 
    public sealed class SwitchAttribute : Attribute {
        private Type type; 
        private string name; 
        private string description;
 
    	public SwitchAttribute (string switchName, Type switchType) {
    	    SwitchName = switchName;
    	    SwitchType = switchType;
        } 

    	public string SwitchName { 
    	    get { return name; } 
    	    set {
    	        if (value == null) 
                    throw new ArgumentNullException("value");
                if (value.Length == 0)
    	            throw new ArgumentException(SR.GetString(SR.InvalidNullEmptyArgument, "value"), "value");
 
    	        name = value;
 	        } 
        } 

    	public Type SwitchType { 
    	    get { return type; }
    	    set {
    	        if (value == null)
    	            throw new ArgumentNullException("value"); 
    	        type = value;
	        } 
        } 

    	public string SwitchDescription { 
    	    get { return description; }
    	    set { description = value;}
        }
 
    	public static SwitchAttribute[] GetAll(Assembly assembly) {
    	    if (assembly == null) 
    	        throw new ArgumentNullException("assembly"); 

    	    ArrayList  switchAttribs = new ArrayList (); 

    	    object[] attribs = assembly.GetCustomAttributes(typeof(SwitchAttribute), false);
    	    switchAttribs.AddRange(attribs);
 
    	    Type[] types = assembly.GetTypes();
    	    for (int i=0; i

                        

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