Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ValidationContext.cs
Go to the documentation of this file.
3
5
7{
9
10 private string _displayName;
11
13
14 public object ObjectInstance { get; }
15
16 public Type ObjectType => ObjectInstance.GetType();
17
18 public string DisplayName
19 {
20 get
21 {
22 if (string.IsNullOrEmpty(_displayName))
23 {
25 if (string.IsNullOrEmpty(_displayName))
26 {
28 }
29 }
30 return _displayName;
31 }
32 set
33 {
34 if (string.IsNullOrEmpty(value))
35 {
36 throw new ArgumentNullException("value");
37 }
39 }
40 }
41
42 public string? MemberName { get; set; }
43
45
46 [RequiresUnreferencedCode("The Type of instance cannot be statically discovered.")]
47 public ValidationContext(object instance)
48 : this(instance, null, null)
49 {
50 }
51
52 [RequiresUnreferencedCode("The Type of instance cannot be statically discovered.")]
53 public ValidationContext(object instance, IDictionary<object, object?>? items)
54 : this(instance, null, items)
55 {
56 }
57
58 [RequiresUnreferencedCode("The Type of instance cannot be statically discovered.")]
60 {
61 if (instance == null)
62 {
63 throw new ArgumentNullException("instance");
64 }
65 if (serviceProvider != null)
66 {
69 }
70 _items = ((items != null) ? new Dictionary<object, object>(items) : new Dictionary<object, object>());
71 ObjectInstance = instance;
72 }
73
74 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "The ctors are marked with RequiresUnreferencedCode.")]
75 private string GetDisplayName()
76 {
77 string text = null;
80 if (string.IsNullOrEmpty(MemberName))
81 {
83 }
84 else if (instance.IsPropertyContext(this))
85 {
87 }
88 if (displayAttribute != null)
89 {
90 text = displayAttribute.GetName();
91 }
92 return text ?? MemberName;
93 }
94
99
101 {
102 return _serviceProvider?.Invoke(serviceType);
103 }
104}
DisplayAttribute GetTypeDisplayAttribute(ValidationContext validationContext)
DisplayAttribute GetPropertyDisplayAttribute(ValidationContext validationContext)
ValidationContext(object instance, IServiceProvider? serviceProvider, IDictionary< object, object?>? items)
void InitializeServiceProvider(Func< Type, object?> serviceProvider)
ValidationContext(object instance, IDictionary< object, object?>? items)