Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ValidationAttributeStore.cs
Go to the documentation of this file.
3using System.Linq;
4
6
7internal sealed class ValidationAttributeStore
8{
9 private abstract class StoreItem
10 {
12
14
15 internal StoreItem(AttributeCollection attributes)
16 {
17 ValidationAttributes = attributes.OfType<ValidationAttribute>();
18 DisplayAttribute = attributes.OfType<DisplayAttribute>().SingleOrDefault();
19 }
20 }
21
22 private sealed class TypeStoreItem : StoreItem
23 {
24 private readonly object _syncRoot = new object();
25
27 private readonly Type _type;
28
30
36
37 [RequiresUnreferencedCode("The Types of _type's properties cannot be statically discovered.")]
46
47 [RequiresUnreferencedCode("The Types of _type's properties cannot be statically discovered.")]
49 {
50 if (string.IsNullOrEmpty(propertyName))
51 {
52 throw new ArgumentNullException("propertyName");
53 }
54 if (_propertyStoreItems == null)
55 {
57 {
58 if (_propertyStoreItems == null)
59 {
61 }
62 }
63 }
65 }
66
67 [RequiresUnreferencedCode("The Types of _type's properties cannot be statically discovered.")]
79
80 [RequiresUnreferencedCode("The Type of propertyDescriptor.PropertyType cannot be statically discovered.")]
82 {
83 AttributeCollection attributes = propertyDescriptor.Attributes;
84 List<Attribute> list = new List<Attribute>(attributes.Count);
85 foreach (Attribute item in attributes)
86 {
87 list.Add(item);
88 }
90 bool flag = false;
91 foreach (Attribute item2 in attributes2)
92 {
93 for (int num = list.Count - 1; num >= 0; num--)
94 {
95 if (item2 == list[num])
96 {
97 list.RemoveAt(num);
98 flag = true;
99 }
100 }
101 }
102 if (!flag)
103 {
104 return attributes;
105 }
106 return new AttributeCollection(list.ToArray());
107 }
108 }
109
110 private sealed class PropertyStoreItem : StoreItem
111 {
112 internal Type PropertyType { get; }
113
115 : base(attributes)
116 {
118 }
119 }
120
122
124
125
126 [RequiresUnreferencedCode("The Type of validationContext.ObjectType cannot be statically discovered.")]
133
134 [RequiresUnreferencedCode("The Type of validationContext.ObjectType cannot be statically discovered.")]
141
142 [RequiresUnreferencedCode("The Type of validationContext.ObjectType cannot be statically discovered.")]
150
151 [RequiresUnreferencedCode("The Type of validationContext.ObjectType cannot be statically discovered.")]
159
160 [RequiresUnreferencedCode("The Type of validationContext.ObjectType cannot be statically discovered.")]
168
169 [RequiresUnreferencedCode("The Type of validationContext.ObjectType cannot be statically discovered.")]
177
191
193 {
194 if (validationContext == null)
195 {
196 throw new ArgumentNullException("validationContext");
197 }
198 }
199}
bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value)
AttributeCollection GetExplicitAttributes(PropertyDescriptor propertyDescriptor)
TypeStoreItem([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type type, AttributeCollection attributes)
bool TryGetPropertyStoreItem(string propertyName, [NotNullWhen(true)] out PropertyStoreItem item)
IEnumerable< ValidationAttribute > GetTypeValidationAttributes(ValidationContext validationContext)
DisplayAttribute GetTypeDisplayAttribute(ValidationContext validationContext)
DisplayAttribute GetPropertyDisplayAttribute(ValidationContext validationContext)
static void EnsureValidationContext(ValidationContext validationContext)
TypeStoreItem GetTypeStoreItem([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type type)
IEnumerable< ValidationAttribute > GetPropertyValidationAttributes(ValidationContext validationContext)
static PropertyDescriptorCollection GetProperties([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type componentType)
static AttributeCollection GetAttributes([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type componentType)
static string AttributeStore_Unknown_Property
Definition SR.cs:18
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
Definition SR.cs:7