mscorlib(4.0.0.0) API with additions
InheritanceAttribute.cs
1 namespace System.ComponentModel
2 {
4  [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event)]
5  public sealed class InheritanceAttribute : Attribute
6  {
7  private readonly InheritanceLevel inheritanceLevel;
8 
10  public static readonly InheritanceAttribute Inherited = new InheritanceAttribute(InheritanceLevel.Inherited);
11 
13  public static readonly InheritanceAttribute InheritedReadOnly = new InheritanceAttribute(InheritanceLevel.InheritedReadOnly);
14 
16  public static readonly InheritanceAttribute NotInherited = new InheritanceAttribute(InheritanceLevel.NotInherited);
17 
19  public static readonly InheritanceAttribute Default = NotInherited;
20 
23  public InheritanceLevel InheritanceLevel => inheritanceLevel;
24 
27  {
28  inheritanceLevel = Default.inheritanceLevel;
29  }
30 
33  public InheritanceAttribute(InheritanceLevel inheritanceLevel)
34  {
35  this.inheritanceLevel = inheritanceLevel;
36  }
37 
42  public override bool Equals(object value)
43  {
44  if (value == this)
45  {
46  return true;
47  }
48  if (!(value is InheritanceAttribute))
49  {
50  return false;
51  }
52  InheritanceLevel inheritanceLevel = ((InheritanceAttribute)value).InheritanceLevel;
53  return inheritanceLevel == this.inheritanceLevel;
54  }
55 
58  public override int GetHashCode()
59  {
60  return base.GetHashCode();
61  }
62 
66  public override bool IsDefaultAttribute()
67  {
68  return Equals(Default);
69  }
70 
73  public override string ToString()
74  {
76  }
77  }
78 }
static readonly InheritanceAttribute Inherited
Specifies that the component is inherited. This field is read-only.
static readonly InheritanceAttribute NotInherited
Specifies that the component is not inherited. This field is read-only.
static readonly InheritanceAttribute InheritedReadOnly
Specifies that the component is inherited and is read-only. This field is read-only.
static TypeConverter GetConverter(object component)
Returns a type converter for the type of the specified component.
Represents the base class for custom attributes.
Definition: Attribute.cs:15
override bool IsDefaultAttribute()
Gets a value indicating whether the current value of the attribute is the default value for the attri...
InheritanceLevel
Defines identifiers for types of inheritance levels.
override bool Equals(object value)
Override to test for equality.
Indicates whether the component associated with this attribute has been inherited from a base class....
override int GetHashCode()
Returns the hashcode for this object.
Provides information about the characteristics for a component, such as its attributes,...
static readonly InheritanceAttribute Default
Specifies that the default value for T:System.ComponentModel.InheritanceAttribute is F:System....
AttributeTargets
Specifies the application elements on which it is valid to apply an attribute.
InheritanceAttribute(InheritanceLevel inheritanceLevel)
Initializes a new instance of the T:System.ComponentModel.InheritanceAttribute class with the specifi...
string ConvertToString(object value)
Converts the specified value to a string representation.
override string ToString()
Converts this attribute to a string.
InheritanceAttribute()
Initializes a new instance of the T:System.ComponentModel.InheritanceAttribute class.