Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ WriteTypeInfo()

string System.Xml.Serialization.ReflectionAwareCodeGen.WriteTypeInfo ( TypeScope scope,
TypeDesc typeDesc,
Type type )
inlineprivate

Definition at line 36 of file ReflectionAwareCodeGen.cs.

37 {
39 string cSharpName = typeDesc.CSharpName;
41 if (text != null)
42 {
43 return text;
44 }
45 if (type.IsArray)
46 {
47 text = GenerateVariableName("array", typeDesc.CSharpName);
48 TypeDesc arrayElementTypeDesc = typeDesc.ArrayElementTypeDesc;
49 if (arrayElementTypeDesc.UseReflection)
50 {
51 string text2 = WriteTypeInfo(scope, arrayElementTypeDesc, scope.GetTypeFromTypeDesc(arrayElementTypeDesc));
52 _writer.WriteLine("static " + typeof(Type).FullName + " " + text + " = " + text2 + ".MakeArrayType();");
53 }
54 else
55 {
57 _writer.Write("static " + typeof(Type).FullName + " " + text + " = " + text3 + ".GetType(");
59 _writer.WriteLine(");");
60 }
61 }
62 else
63 {
64 text = GenerateVariableName("type", typeDesc.CSharpName);
65 Type underlyingType = Nullable.GetUnderlyingType(type);
66 if (underlyingType != null)
67 {
68 string text4 = WriteTypeInfo(scope, scope.GetTypeDesc(underlyingType), underlyingType);
69 _writer.WriteLine("static " + typeof(Type).FullName + " " + text + " = typeof(System.Nullable<>).MakeGenericType(new " + typeof(Type).FullName + "[] {" + text4 + "});");
70 }
71 else
72 {
74 _writer.Write("static " + typeof(Type).FullName + " " + text + " = " + text5 + ".GetType(");
76 _writer.WriteLine(");");
77 }
78 }
80 TypeMapping typeMappingFromTypeDesc = scope.GetTypeMappingFromTypeDesc(typeDesc);
81 if (typeMappingFromTypeDesc != null)
82 {
84 }
85 if (typeDesc.IsCollection || typeDesc.IsEnumerable)
86 {
87 TypeDesc arrayElementTypeDesc2 = typeDesc.ArrayElementTypeDesc;
88 if (arrayElementTypeDesc2.UseReflection)
89 {
90 WriteTypeInfo(scope, arrayElementTypeDesc2, scope.GetTypeFromTypeDesc(arrayElementTypeDesc2));
91 }
93 }
94 return text;
95 }
virtual void Add(object key, object? value)
Definition Hashtable.cs:676
static void WriteQuotedCSharpString(IndentedWriter writer, string value)
void WriteCollectionInfo(string typeVariable, TypeDesc typeDesc, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors|DynamicallyAccessedMemberTypes.PublicMethods|DynamicallyAccessedMemberTypes.PublicFields|DynamicallyAccessedMemberTypes.PublicNestedTypes|DynamicallyAccessedMemberTypes.PublicProperties|DynamicallyAccessedMemberTypes.PublicEvents)] Type type)
string WriteTypeInfo(TypeScope scope, TypeDesc typeDesc, Type type)
string GenerateVariableName(string prefix, string fullName)
void WriteMappingInfo(TypeMapping mapping, string typeVariable, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors|DynamicallyAccessedMemberTypes.PublicMethods|DynamicallyAccessedMemberTypes.PublicFields|DynamicallyAccessedMemberTypes.PublicNestedTypes|DynamicallyAccessedMemberTypes.PublicProperties|DynamicallyAccessedMemberTypes.PublicEvents)] Type type)

References System.Xml.Serialization.ReflectionAwareCodeGen._reflectionVariables, System.Xml.Serialization.ReflectionAwareCodeGen._writer, System.Collections.Hashtable.Add(), System.Xml.Serialization.TypeDesc.ArrayElementTypeDesc, System.Xml.Dictionary, System.FullName, System.Xml.Serialization.ReflectionAwareCodeGen.GenerateVariableName(), System.Xml.Serialization.TypeScope.GetTypeDesc(), System.Xml.Serialization.TypeScope.GetTypeFromTypeDesc(), System.Xml.Serialization.TypeScope.GetTypeMappingFromTypeDesc(), System.Nullable< T >.GetUnderlyingType(), System.Xml.Serialization.ReflectionAwareCodeGen.InitTheFirstTime(), System.text, System.type, System.Xml.Serialization.IndentedWriter.Write(), System.Xml.Serialization.ReflectionAwareCodeGen.WriteAssemblyInfo(), System.Xml.Serialization.ReflectionAwareCodeGen.WriteCollectionInfo(), System.Xml.Serialization.IndentedWriter.WriteLine(), System.Xml.Serialization.ReflectionAwareCodeGen.WriteMappingInfo(), System.Xml.Serialization.ReflectionAwareCodeGen.WriteQuotedCSharpString(), and System.Xml.Serialization.ReflectionAwareCodeGen.WriteTypeInfo().

Referenced by System.Xml.Serialization.ReflectionAwareCodeGen.WriteReflectionInit(), and System.Xml.Serialization.ReflectionAwareCodeGen.WriteTypeInfo().