comparison Source/Reflection/Extension/AttributeExtension.cs @ 0:f990fcb411a9

Копия текущей версии из github
author cin
date Thu, 27 Mar 2014 21:46:09 +0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f990fcb411a9
1 using System;
2
3 namespace BLToolkit.Reflection.Extension
4 {
5 public class AttributeExtension
6 {
7 public AttributeExtension()
8 {
9 Values = new ValueCollection();
10 }
11
12 private AttributeExtension(ValueCollection values)
13 {
14 Values = values;
15 }
16
17 public string Name { get; set; }
18 public ValueCollection Values { get; private set; }
19
20 public object Value
21 {
22 get { return this == _null? null: Values.Value; }
23 }
24
25 public object this[string valueName]
26 {
27 get { return this == _null? null: Values[valueName]; }
28 }
29
30 public object this[string valueName, object defaultValue]
31 {
32 get { return this[valueName] ?? defaultValue; }
33 }
34
35 private AttributeNameCollection _attributes;
36 public AttributeNameCollection Attributes
37 {
38 get { return _attributes ?? (_attributes = new AttributeNameCollection()); }
39 }
40
41 private static readonly AttributeExtension _null = new AttributeExtension(ValueCollection.Null);
42 public static AttributeExtension Null
43 {
44 get { return _null; }
45 }
46 }
47 }