Terraria v1.4.4.9
Terraria source code documentation
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Macros
AssociatedMetadataTypeTypeDescriptor.cs
Go to the documentation of this file.
4using System.Linq;
6
8
10{
11 private static class TypeDescriptorCache
12 {
14
15 private static readonly ConcurrentDictionary<(Type, string), Attribute[]> s_typeMemberCache = new ConcurrentDictionary<(Type, string), Attribute[]>();
16
17 private static readonly ConcurrentDictionary<(Type, Type), bool> s_validatedMetadataTypeCache = new ConcurrentDictionary<(Type, Type), bool>();
18
28
44
60
62 {
64 if (s_typeMemberCache.TryGetValue(key, out var value))
65 {
66 return value;
67 }
68 MemberTypes type2 = MemberTypes.Field | MemberTypes.Property;
69 BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public;
70 MemberInfo memberInfo = type.GetMember(memberName, type2, bindingAttr).FirstOrDefault();
71 value = ((!(memberInfo != null)) ? Array.Empty<Attribute>() : Attribute.GetCustomAttributes(memberInfo, inherit: true));
73 return value;
74 }
75 }
76
78 private Type AssociatedMetadataType { get; set; }
79
80 private bool IsSelfAssociated { get; set; }
81
92
93 [RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
95 {
96 return GetPropertiesWithMetadata(base.GetProperties(attributes));
97 }
98
99 [RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered.")]
101 {
102 return GetPropertiesWithMetadata(base.GetProperties());
103 }
104
130
141}
static ? Attribute GetCustomAttribute(MemberInfo element, Type attributeType)
Definition Attribute.cs:411
static Attribute[] GetCustomAttributes(MemberInfo element, Type attributeType)
Definition Attribute.cs:338
static AttributeCollection FromExisting(AttributeCollection existing, params Attribute[]? newAttributes)
static Attribute[] GetAssociatedMetadata([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type type, string memberName)
static void CheckAssociatedMetadataType([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] Type mainType, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields|DynamicallyAccessedMemberTypes.PublicProperties)] Type associatedMetadataType)
static void ValidateMetadataType([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] Type type, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields|DynamicallyAccessedMemberTypes.PublicProperties)] Type associatedType)
AssociatedMetadataTypeTypeDescriptor(ICustomTypeDescriptor parent, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] Type type, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type associatedMetadataType)
PropertyDescriptorCollection GetPropertiesWithMetadata(PropertyDescriptorCollection originalCollection)
static AttributeCollection GetAttributes([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type componentType)
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string AssociatedMetadataTypeTypeDescriptor_MetadataTypeContainsUnknownProperties
Definition SR.cs:16
Definition SR.cs:7
static StringComparer Ordinal