namespace System.ComponentModel.DataAnnotations {
///
/// Indicates whether the consumer of a field or property, such as a client application,
/// should allow editing of the value.
///
///
/// This attribute neither enforces nor guarantees editability; the underlying data
/// store might allow changing the data regardless of this attribute. The presence
/// of this attribute signals intent to the consumer of the attribute whethere or not
/// the end user should be allowed to change the value via the client application.
///
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
public sealed class EditableAttribute : Attribute {
///
/// Indicates whether or not the field/property allows editing of the
/// value.
///
///
/// When true, the field/property is editable.
///
/// When false, the field/property is not editable.
///
///
public bool AllowEdit { get; private set; }
///
/// Indicates whether or not the field/property allows an initial value
/// to be specified.
///
///
/// The value of this property defaults to match the
/// property value specified in the constructor.
///
///
/// When true, the field/property can have its value set for
/// newly constructed instances, such as during an insert operation.
///
/// When false, the field/property cannot have its
/// value provided for newly constructed instances, such as during
/// an insert operation. This will often indicate that the value
/// is auto-generated by the persistence store.
///
///
public bool AllowInitialValue { get; set; }
///
/// Indicate whether or not a field/property is editable.
///
///
/// Indicates whether the field/property is editable. The value provided
/// will apply to both and
/// unless the
/// property is explicitly specified.
///
public EditableAttribute(bool allowEdit) {
this.AllowEdit = allowEdit;
this.AllowInitialValue = allowEdit;
}
}
}