mscorlib(4.0.0.0) API with additions
CategoryAttribute.cs
1 namespace System.ComponentModel
2 {
4  [AttributeUsage(AttributeTargets.All)]
5  public class CategoryAttribute : Attribute
6  {
7  private static volatile CategoryAttribute appearance;
8 
9  private static volatile CategoryAttribute asynchronous;
10 
11  private static volatile CategoryAttribute behavior;
12 
13  private static volatile CategoryAttribute data;
14 
15  private static volatile CategoryAttribute design;
16 
17  private static volatile CategoryAttribute action;
18 
19  private static volatile CategoryAttribute format;
20 
21  private static volatile CategoryAttribute layout;
22 
23  private static volatile CategoryAttribute mouse;
24 
25  private static volatile CategoryAttribute key;
26 
27  private static volatile CategoryAttribute focus;
28 
29  private static volatile CategoryAttribute windowStyle;
30 
31  private static volatile CategoryAttribute dragDrop;
32 
33  private static volatile CategoryAttribute defAttr;
34 
35  private bool localized;
36 
37  private string categoryValue;
38 
41  public static CategoryAttribute Action
42  {
43  get
44  {
45  if (action == null)
46  {
47  action = new CategoryAttribute("Action");
48  }
49  return action;
50  }
51  }
52 
55  public static CategoryAttribute Appearance
56  {
57  get
58  {
59  if (appearance == null)
60  {
61  appearance = new CategoryAttribute("Appearance");
62  }
63  return appearance;
64  }
65  }
66 
69  public static CategoryAttribute Asynchronous
70  {
71  get
72  {
73  if (asynchronous == null)
74  {
75  asynchronous = new CategoryAttribute("Asynchronous");
76  }
77  return asynchronous;
78  }
79  }
80 
83  public static CategoryAttribute Behavior
84  {
85  get
86  {
87  if (behavior == null)
88  {
89  behavior = new CategoryAttribute("Behavior");
90  }
91  return behavior;
92  }
93  }
94 
97  public static CategoryAttribute Data
98  {
99  get
100  {
101  if (data == null)
102  {
103  data = new CategoryAttribute("Data");
104  }
105  return data;
106  }
107  }
108 
111  public static CategoryAttribute Default
112  {
113  get
114  {
115  if (defAttr == null)
116  {
117  defAttr = new CategoryAttribute();
118  }
119  return defAttr;
120  }
121  }
122 
125  public static CategoryAttribute Design
126  {
127  get
128  {
129  if (design == null)
130  {
131  design = new CategoryAttribute("Design");
132  }
133  return design;
134  }
135  }
136 
139  public static CategoryAttribute DragDrop
140  {
141  get
142  {
143  if (dragDrop == null)
144  {
145  dragDrop = new CategoryAttribute("DragDrop");
146  }
147  return dragDrop;
148  }
149  }
150 
153  public static CategoryAttribute Focus
154  {
155  get
156  {
157  if (focus == null)
158  {
159  focus = new CategoryAttribute("Focus");
160  }
161  return focus;
162  }
163  }
164 
167  public static CategoryAttribute Format
168  {
169  get
170  {
171  if (format == null)
172  {
173  format = new CategoryAttribute("Format");
174  }
175  return format;
176  }
177  }
178 
181  public static CategoryAttribute Key
182  {
183  get
184  {
185  if (key == null)
186  {
187  key = new CategoryAttribute("Key");
188  }
189  return key;
190  }
191  }
192 
195  public static CategoryAttribute Layout
196  {
197  get
198  {
199  if (layout == null)
200  {
201  layout = new CategoryAttribute("Layout");
202  }
203  return layout;
204  }
205  }
206 
209  public static CategoryAttribute Mouse
210  {
211  get
212  {
213  if (mouse == null)
214  {
215  mouse = new CategoryAttribute("Mouse");
216  }
217  return mouse;
218  }
219  }
220 
223  public static CategoryAttribute WindowStyle
224  {
225  get
226  {
227  if (windowStyle == null)
228  {
229  windowStyle = new CategoryAttribute("WindowStyle");
230  }
231  return windowStyle;
232  }
233  }
234 
237  public string Category
238  {
239  get
240  {
241  if (!localized)
242  {
243  localized = true;
244  string localizedString = GetLocalizedString(categoryValue);
245  if (localizedString != null)
246  {
247  categoryValue = localizedString;
248  }
249  }
250  return categoryValue;
251  }
252  }
253 
256  : this("Default")
257  {
258  }
259 
262  public CategoryAttribute(string category)
263  {
264  categoryValue = category;
265  localized = false;
266  }
267 
272  public override bool Equals(object obj)
273  {
274  if (obj == this)
275  {
276  return true;
277  }
278  if (obj is CategoryAttribute)
279  {
280  return Category.Equals(((CategoryAttribute)obj).Category);
281  }
282  return false;
283  }
284 
287  public override int GetHashCode()
288  {
289  return Category.GetHashCode();
290  }
291 
295  protected virtual string GetLocalizedString(string value)
296  {
297  return (string)SR.GetObject("PropertyCategory" + value);
298  }
299 
303  public override bool IsDefaultAttribute()
304  {
305  return Category.Equals(Default.Category);
306  }
307  }
308 }
static CategoryAttribute Asynchronous
Gets a T:System.ComponentModel.CategoryAttribute representing the Asynchronous category.
static CategoryAttribute Focus
Gets a T:System.ComponentModel.CategoryAttribute representing the Focus category.
static CategoryAttribute Key
Gets a T:System.ComponentModel.CategoryAttribute representing the Key category.
static CategoryAttribute Default
Gets a T:System.ComponentModel.CategoryAttribute representing the Default category.
Represents the base class for custom attributes.
Definition: Attribute.cs:15
static CategoryAttribute Layout
Gets a T:System.ComponentModel.CategoryAttribute representing the Layout category.
static CategoryAttribute WindowStyle
Gets a T:System.ComponentModel.CategoryAttribute representing the WindowStyle category.
CategoryAttribute()
Initializes a new instance of the T:System.ComponentModel.CategoryAttribute class using the category ...
string Category
Gets the name of the category for the property or event that this attribute is applied to.
Specifies the name of the category in which to group the property or event when displayed in a T:Syst...
override int GetHashCode()
Returns the hash code for this attribute.
static CategoryAttribute DragDrop
Gets a T:System.ComponentModel.CategoryAttribute representing the DragDrop category.
static CategoryAttribute Behavior
Gets a T:System.ComponentModel.CategoryAttribute representing the Behavior category.
AttributeTargets
Specifies the application elements on which it is valid to apply an attribute.
virtual string GetLocalizedString(string value)
Looks up the localized name of the specified category.
static CategoryAttribute Format
Gets a T:System.ComponentModel.CategoryAttribute representing the Format category.
static CategoryAttribute Mouse
Gets a T:System.ComponentModel.CategoryAttribute representing the Mouse category.
static CategoryAttribute Appearance
Gets a T:System.ComponentModel.CategoryAttribute representing the Appearance category.
override bool IsDefaultAttribute()
Determines if this attribute is the default.
static CategoryAttribute Data
Gets a T:System.ComponentModel.CategoryAttribute representing the Data category.
static CategoryAttribute Design
Gets a T:System.ComponentModel.CategoryAttribute representing the Design category.
override bool Equals(object obj)
Returns whether the value of the given object is equal to the current T:System.ComponentModel....
CategoryAttribute(string category)
Initializes a new instance of the T:System.ComponentModel.CategoryAttribute class using the specified...
static CategoryAttribute Action
Gets a T:System.ComponentModel.CategoryAttribute representing the Action category.