Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ReflectionXmlSerializationHelper.cs
Go to the documentation of this file.
3
5
7{
8 [RequiresUnreferencedCode("Reflects over base members")]
10 {
11 MemberInfo[] member = declaringType.GetMember(memberName);
12 if (member == null || member.Length == 0)
13 {
14 bool flag = false;
16 while (baseType != null)
17 {
18 member = baseType.GetMember(memberName);
19 if (member != null && member.Length != 0)
20 {
21 flag = true;
22 break;
23 }
24 baseType = baseType.BaseType;
25 }
26 if (!flag)
27 {
29 {
30 throw new InvalidOperationException(System.SR.Format(System.SR.XmlInternalErrorDetails, $"Could not find member named {memberName} of type {declaringType}"));
31 }
32 return null;
33 }
35 }
36 MemberInfo result = member[0];
37 if (member.Length != 1)
38 {
39 MemberInfo[] array = member;
40 foreach (MemberInfo memberInfo in array)
41 {
42 if (declaringType == memberInfo.DeclaringType)
43 {
44 result = memberInfo;
45 break;
46 }
47 }
48 }
49 return result;
50 }
51
52 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly")]
54 {
56 if (member is PropertyInfo propertyInfo && propertyInfo.GetMethod == null)
57 {
59 while (baseType != null)
60 {
62 if (member2 is PropertyInfo propertyInfo2 && propertyInfo2.GetMethod != null && propertyInfo2.PropertyType == propertyInfo.PropertyType)
63 {
64 return propertyInfo2;
65 }
66 baseType = baseType.BaseType;
67 }
68 }
69 return member;
70 }
71
72 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly")]
74 {
76 if (member is PropertyInfo propertyInfo && propertyInfo.SetMethod == null)
77 {
79 while (baseType != null)
80 {
82 if (member2 is PropertyInfo propertyInfo2 && propertyInfo2.SetMethod != null && propertyInfo2.PropertyType == propertyInfo.PropertyType)
83 {
84 return propertyInfo2;
85 }
86 baseType = baseType.BaseType;
87 }
88 }
89 return member;
90 }
91}
virtual ? MethodInfo GetMethod
virtual ? MethodInfo SetMethod
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string XmlInternalErrorDetails
Definition SR.cs:1814
Definition SR.cs:7
Type? BaseType
Definition Type.cs:295
static MemberInfo GetEffectiveGetInfo(Type declaringType, string memberName)
static MemberInfo GetEffectiveSetInfo(Type declaringType, string memberName)
static MemberInfo GetMember(Type declaringType, string memberName, bool throwOnNotFound)