mscorlib(4.0.0.0) API with additions
DefaultValueAttribute.cs
1 namespace System.ComponentModel
2 {
4  [AttributeUsage(AttributeTargets.All)]
5  [global::__DynamicallyInvokable]
7  {
8  private object value;
9 
12  [global::__DynamicallyInvokable]
13  public virtual object Value
14  {
15  [global::__DynamicallyInvokable]
16  get
17  {
18  return value;
19  }
20  }
21 
25  [global::__DynamicallyInvokable]
26  public DefaultValueAttribute(Type type, string value)
27  {
28  try
29  {
30  this.value = TypeDescriptor.GetConverter(type).ConvertFromInvariantString(value);
31  }
32  catch
33  {
34  }
35  }
36 
39  [global::__DynamicallyInvokable]
40  public DefaultValueAttribute(char value)
41  {
42  this.value = value;
43  }
44 
47  [global::__DynamicallyInvokable]
48  public DefaultValueAttribute(byte value)
49  {
50  this.value = value;
51  }
52 
55  [global::__DynamicallyInvokable]
56  public DefaultValueAttribute(short value)
57  {
58  this.value = value;
59  }
60 
63  [global::__DynamicallyInvokable]
64  public DefaultValueAttribute(int value)
65  {
66  this.value = value;
67  }
68 
71  [global::__DynamicallyInvokable]
72  public DefaultValueAttribute(long value)
73  {
74  this.value = value;
75  }
76 
79  [global::__DynamicallyInvokable]
80  public DefaultValueAttribute(float value)
81  {
82  this.value = value;
83  }
84 
87  [global::__DynamicallyInvokable]
88  public DefaultValueAttribute(double value)
89  {
90  this.value = value;
91  }
92 
95  [global::__DynamicallyInvokable]
96  public DefaultValueAttribute(bool value)
97  {
98  this.value = value;
99  }
100 
103  [global::__DynamicallyInvokable]
104  public DefaultValueAttribute(string value)
105  {
106  this.value = value;
107  }
108 
111  [global::__DynamicallyInvokable]
112  public DefaultValueAttribute(object value)
113  {
114  this.value = value;
115  }
116 
121  [global::__DynamicallyInvokable]
122  public override bool Equals(object obj)
123  {
124  if (obj == this)
125  {
126  return true;
127  }
128  DefaultValueAttribute defaultValueAttribute = obj as DefaultValueAttribute;
129  if (defaultValueAttribute != null)
130  {
131  if (Value != null)
132  {
133  return Value.Equals(defaultValueAttribute.Value);
134  }
135  return defaultValueAttribute.Value == null;
136  }
137  return false;
138  }
139 
142  [global::__DynamicallyInvokable]
143  public override int GetHashCode()
144  {
145  return base.GetHashCode();
146  }
147 
150  protected void SetValue(object value)
151  {
152  this.value = value;
153  }
154  }
155 }
Specifies the default value for a property.
override int GetHashCode()
Returns the hash code for this instance.
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
DefaultValueAttribute(short value)
Initializes a new instance of the T:System.ComponentModel.DefaultValueAttribute class using a 16-bit ...
DefaultValueAttribute(int value)
Initializes a new instance of the T:System.ComponentModel.DefaultValueAttribute class using a 32-bit ...
DefaultValueAttribute(double value)
Initializes a new instance of the T:System.ComponentModel.DefaultValueAttribute class using a double-...
void SetValue(object value)
Sets the default value for the property to which this attribute is bound.
DefaultValueAttribute(object value)
Initializes a new instance of the T:System.ComponentModel.DefaultValueAttribute class.
virtual object Value
Gets the default value of the property this attribute is bound to.
DefaultValueAttribute(byte value)
Initializes a new instance of the T:System.ComponentModel.DefaultValueAttribute class using an 8-bit ...
Represents type declarations: class types, interface types, array types, value types,...
Definition: Type.cs:18
Provides information about the characteristics for a component, such as its attributes,...
AttributeTargets
Specifies the application elements on which it is valid to apply an attribute.
DefaultValueAttribute(char value)
Initializes a new instance of the T:System.ComponentModel.DefaultValueAttribute class using a Unicode...
DefaultValueAttribute(bool value)
Initializes a new instance of the T:System.ComponentModel.DefaultValueAttribute class using a T:Syste...
DefaultValueAttribute(Type type, string value)
Initializes a new instance of the T:System.ComponentModel.DefaultValueAttribute class,...
DefaultValueAttribute(string value)
Initializes a new instance of the T:System.ComponentModel.DefaultValueAttribute class using a T:Syste...
DefaultValueAttribute(float value)
Initializes a new instance of the T:System.ComponentModel.DefaultValueAttribute class using a single-...
object ConvertFromInvariantString(string text)
Converts the given string to the type of this converter, using the invariant culture.
override bool Equals(object obj)
Returns whether the value of the given object is equal to the current T:System.ComponentModel....
DefaultValueAttribute(long value)
Initializes a new instance of the T:System.ComponentModel.DefaultValueAttribute class using a 64-bit ...