File: EditableAttribute.cs

package info (click to toggle)
mono 6.12.0.199%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 1,296,836 kB
  • sloc: cs: 11,181,803; xml: 2,850,076; ansic: 699,709; cpp: 123,344; perl: 59,361; javascript: 30,841; asm: 21,853; makefile: 20,405; sh: 15,009; python: 4,839; pascal: 925; sql: 859; sed: 16; php: 1
file content (61 lines) | stat: -rw-r--r-- 2,689 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61

namespace System.ComponentModel.DataAnnotations {
    /// <summary>
    /// Indicates whether the consumer of a field or property, such as a client application,
    /// should allow editing of the value.
    /// </summary>
    /// <remarks>
    /// 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.
    /// </remarks>
    [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
    public sealed class EditableAttribute : Attribute {
        /// <summary>
        /// Indicates whether or not the field/property allows editing of the
        /// value.
        /// </summary>
        /// <value>
        /// When <c>true</c>, the field/property is editable.
        /// <para>
        /// When <c>false</c>, the field/property is not editable.
        /// </para>
        /// </value>
        public bool AllowEdit { get; private set; }

        /// <summary>
        /// Indicates whether or not the field/property allows an initial value
        /// to be specified.
        /// </summary>
        /// <remarks>
        /// The value of this property defaults to match the <see cref="AllowEdit"/>
        /// property value specified in the constructor.
        /// </remarks>
        /// <value>
        /// When <c>true</c>, the field/property can have its value set for
        /// newly constructed instances, such as during an insert operation.
        /// <para>
        /// When <c>false</c>, 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.
        /// </para>
        /// </value>
        public bool AllowInitialValue { get; set; }

        /// <summary>
        /// Indicate whether or not a field/property is editable.
        /// </summary>
        /// <param name="allowEdit">
        /// Indicates whether the field/property is editable.  The value provided
        /// will apply to both <see cref="AllowEdit"/> and
        /// <see cref="AllowInitialValue"/> unless the <see cref="AllowInitialValue"/>
        /// property is explicitly specified.
        /// </param>
        public EditableAttribute(bool allowEdit) {
            this.AllowEdit = allowEdit;
            this.AllowInitialValue = allowEdit;
        }
    }
}