//------------------------------------------------------------------------------
//
// 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);
}
}
}