Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
BinaryTypeConverter.cs
Go to the documentation of this file.
2
4
5internal static class BinaryTypeConverter
6{
8 {
9 assemId = 0;
10 typeInformation = null;
11 BinaryTypeEnum result;
12 if ((object)type == Converter.s_typeofString)
13 {
14 result = BinaryTypeEnum.String;
15 }
16 else if ((objectInfo == null || (objectInfo != null && !objectInfo._isSi)) && (object)type == Converter.s_typeofObject)
17 {
18 result = BinaryTypeEnum.Object;
19 }
20 else if ((object)type == Converter.s_typeofStringArray)
21 {
22 result = BinaryTypeEnum.StringArray;
23 }
24 else if ((object)type == Converter.s_typeofObjectArray)
25 {
26 result = BinaryTypeEnum.ObjectArray;
27 }
29 {
30 result = BinaryTypeEnum.PrimitiveArray;
31 }
32 else
33 {
36 {
37 string text = null;
38 if (objectInfo == null)
39 {
40 text = type.Assembly.FullName;
41 typeInformation = type.FullName;
42 }
43 else
44 {
45 text = objectInfo.GetAssemblyString();
46 typeInformation = objectInfo.GetTypeFullName();
47 }
49 {
50 result = BinaryTypeEnum.ObjectUrt;
51 assemId = 0;
52 }
53 else
54 {
55 result = BinaryTypeEnum.ObjectUser;
56 assemId = (int)objectInfo._assemId;
57 if (assemId == 0)
58 {
60 }
61 }
62 }
63 else
64 {
65 result = BinaryTypeEnum.Primitive;
67 }
68 }
69 return result;
70 }
71
73 {
74 typeInformation = null;
75 BinaryTypeEnum result;
76 if ((object)type == Converter.s_typeofString)
77 {
78 result = BinaryTypeEnum.String;
79 }
80 else if ((object)type == Converter.s_typeofObject)
81 {
82 result = BinaryTypeEnum.Object;
83 }
84 else if ((object)type == Converter.s_typeofObjectArray)
85 {
86 result = BinaryTypeEnum.ObjectArray;
87 }
88 else if ((object)type == Converter.s_typeofStringArray)
89 {
90 result = BinaryTypeEnum.StringArray;
91 }
93 {
94 result = BinaryTypeEnum.PrimitiveArray;
95 }
96 else
97 {
100 {
101 result = ((type.Assembly == Converter.s_urtAssembly) ? BinaryTypeEnum.ObjectUrt : BinaryTypeEnum.ObjectUser);
102 typeInformation = type.FullName;
103 }
104 else
105 {
106 result = BinaryTypeEnum.Primitive;
108 }
109 }
110 return result;
111 }
112
114 {
115 switch (binaryTypeEnum)
116 {
117 case BinaryTypeEnum.Primitive:
118 case BinaryTypeEnum.PrimitiveArray:
120 break;
121 case BinaryTypeEnum.ObjectUrt:
122 output.WriteString(typeInformation.ToString());
123 break;
124 case BinaryTypeEnum.ObjectUser:
125 output.WriteString(typeInformation.ToString());
126 output.WriteInt32(assemId);
127 break;
128 default:
130 case BinaryTypeEnum.String:
131 case BinaryTypeEnum.Object:
132 case BinaryTypeEnum.ObjectArray:
133 case BinaryTypeEnum.StringArray:
134 break;
135 }
136 }
137
139 {
140 object result = null;
141 int num = 0;
142 switch (binaryTypeEnum)
143 {
144 case BinaryTypeEnum.Primitive:
145 case BinaryTypeEnum.PrimitiveArray:
146 result = (InternalPrimitiveTypeE)input.ReadByte();
147 break;
148 case BinaryTypeEnum.ObjectUrt:
149 result = input.ReadString();
150 break;
151 case BinaryTypeEnum.ObjectUser:
152 result = input.ReadString();
153 num = input.ReadInt32();
154 break;
155 default:
157 case BinaryTypeEnum.String:
158 case BinaryTypeEnum.Object:
159 case BinaryTypeEnum.ObjectArray:
160 case BinaryTypeEnum.StringArray:
161 break;
162 }
163 assemId = num;
164 return result;
165 }
166
167 [RequiresUnreferencedCode("Types might be removed")]
169 {
170 isVariant = false;
172 typeString = null;
173 type = null;
174 switch (binaryTypeEnum)
175 {
176 case BinaryTypeEnum.Primitive:
180 break;
181 case BinaryTypeEnum.String:
183 break;
184 case BinaryTypeEnum.Object:
186 isVariant = true;
187 break;
188 case BinaryTypeEnum.ObjectArray:
190 break;
191 case BinaryTypeEnum.StringArray:
193 break;
194 case BinaryTypeEnum.PrimitiveArray:
197 break;
198 case BinaryTypeEnum.ObjectUrt:
199 case BinaryTypeEnum.ObjectUser:
200 if (typeInformation != null)
201 {
202 typeString = typeInformation.ToString();
203 type = objectReader.GetType(assemblyInfo, typeString);
204 if ((object)type == Converter.s_typeofObject)
205 {
206 isVariant = true;
207 }
208 }
209 break;
210 default:
212 }
213 }
214}
static void TypeFromInfo(BinaryTypeEnum binaryTypeEnum, object typeInformation, ObjectReader objectReader, BinaryAssemblyInfo assemblyInfo, out InternalPrimitiveTypeE primitiveTypeEnum, out string typeString, out Type type, out bool isVariant)
static BinaryTypeEnum GetParserBinaryTypeInfo(Type type, out object typeInformation)
static BinaryTypeEnum GetBinaryTypeInfo(Type type, WriteObjectInfo objectInfo, string typeName, ObjectWriter objectWriter, out object typeInformation, out int assemId)
static object ReadTypeInfo(BinaryTypeEnum binaryTypeEnum, BinaryParser input, out int assemId)
static void WriteTypeInfo(BinaryTypeEnum binaryTypeEnum, object typeInformation, int assemId, BinaryFormatterWriter output)
static Type ToArrayType(InternalPrimitiveTypeE code)
Definition Converter.cs:172
static bool IsPrimitiveArray(Type type, [NotNullWhen(true)] out object typeInformation)
Definition Converter.cs:231
static InternalPrimitiveTypeE ToCode(Type type)
Definition Converter.cs:105
static string ToComType(InternalPrimitiveTypeE code)
Definition Converter.cs:298
static Type ToType(InternalPrimitiveTypeE code)
Definition Converter.cs:199
static string Serialization_TypeWrite
Definition SR.cs:98
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string Serialization_AssemblyId
Definition SR.cs:92
static string Serialization_TypeRead
Definition SR.cs:100
Definition SR.cs:7