ReadOnlyAttribute.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / CompMod / System / ComponentModel / ReadOnlyAttribute.cs / 1 / ReadOnlyAttribute.cs

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

/* 
 */ 
namespace System.ComponentModel {
 
    using System;
    using System.Diagnostics;
    using System.Security.Permissions;
 
    /// 
    ///    Specifies whether the property this attribute is bound to 
    ///       is read-only or read/write. 
    /// 
    [AttributeUsage(AttributeTargets.All)] 
    public sealed class ReadOnlyAttribute : Attribute {
        private bool isReadOnly = false;

        ///  
        ///    
        ///       Specifies that the property this attribute is bound to is read-only and 
        ///       cannot be modified in the server explorer. This field is 
        ///       read-only.
        ///     
        /// 
        public static readonly ReadOnlyAttribute Yes = new ReadOnlyAttribute(true);

        ///  
        ///    
        ///       Specifies that the property this attribute is bound to is read/write and can 
        ///       be modified at design time. This field is read-only. 
        ///    
        ///  
        public static readonly ReadOnlyAttribute No = new ReadOnlyAttribute(false);

        /// 
        ///     
        ///       Specifies the default value for the  , which is , that is,
        ///       the property this attribute is bound to is read/write. This  field is read-only. 
        ///     
        /// 
        public static readonly ReadOnlyAttribute Default = No; 

        /// 
        ///    
        ///       Initializes a new instance of the  class. 
        ///    
        ///  
        public ReadOnlyAttribute(bool isReadOnly) { 
            this.isReadOnly = isReadOnly;
        } 

        /// 
        ///    
        ///       Gets a value indicating whether the property this attribute is bound to is 
        ///       read-only.
        ///     
        ///  
        public bool IsReadOnly {
            get { 
                return isReadOnly;
            }
        }
 
        /// 
        ///  
        ///  
        public override bool Equals(object value) {
 
            if (this == value) {
                return true;
            }
 
            ReadOnlyAttribute other = value as ReadOnlyAttribute;
 
            return other != null && other.IsReadOnly == IsReadOnly; 
        }
 
        /// 
        ///    
        ///       Returns the hashcode for this object.
        ///     
        /// 
        public override int GetHashCode() { 
            return base.GetHashCode(); 
        }
 
        /// 
        /// 
        ///    
        ///       Determines if this attribute is the default. 
        ///    
        ///  
        public override bool IsDefaultAttribute() { 
            return (this.IsReadOnly == Default.IsReadOnly);
        } 
    }
}


// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------ 
// 
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// 
//----------------------------------------------------------------------------- 

/* 
 */ 
namespace System.ComponentModel {
 
    using System;
    using System.Diagnostics;
    using System.Security.Permissions;
 
    /// 
    ///    Specifies whether the property this attribute is bound to 
    ///       is read-only or read/write. 
    /// 
    [AttributeUsage(AttributeTargets.All)] 
    public sealed class ReadOnlyAttribute : Attribute {
        private bool isReadOnly = false;

        ///  
        ///    
        ///       Specifies that the property this attribute is bound to is read-only and 
        ///       cannot be modified in the server explorer. This field is 
        ///       read-only.
        ///     
        /// 
        public static readonly ReadOnlyAttribute Yes = new ReadOnlyAttribute(true);

        ///  
        ///    
        ///       Specifies that the property this attribute is bound to is read/write and can 
        ///       be modified at design time. This field is read-only. 
        ///    
        ///  
        public static readonly ReadOnlyAttribute No = new ReadOnlyAttribute(false);

        /// 
        ///     
        ///       Specifies the default value for the  , which is , that is,
        ///       the property this attribute is bound to is read/write. This  field is read-only. 
        ///     
        /// 
        public static readonly ReadOnlyAttribute Default = No; 

        /// 
        ///    
        ///       Initializes a new instance of the  class. 
        ///    
        ///  
        public ReadOnlyAttribute(bool isReadOnly) { 
            this.isReadOnly = isReadOnly;
        } 

        /// 
        ///    
        ///       Gets a value indicating whether the property this attribute is bound to is 
        ///       read-only.
        ///     
        ///  
        public bool IsReadOnly {
            get { 
                return isReadOnly;
            }
        }
 
        /// 
        ///  
        ///  
        public override bool Equals(object value) {
 
            if (this == value) {
                return true;
            }
 
            ReadOnlyAttribute other = value as ReadOnlyAttribute;
 
            return other != null && other.IsReadOnly == IsReadOnly; 
        }
 
        /// 
        ///    
        ///       Returns the hashcode for this object.
        ///     
        /// 
        public override int GetHashCode() { 
            return base.GetHashCode(); 
        }
 
        /// 
        /// 
        ///    
        ///       Determines if this attribute is the default. 
        ///    
        ///  
        public override bool IsDefaultAttribute() { 
            return (this.IsReadOnly == Default.IsReadOnly);
        } 
    }
}


// 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