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

◆ InternalConvert()

void System.Xml.Serialization.CodeGenerator.InternalConvert ( Type source,
Type target,
bool isAddress )
inlineprivate

Definition at line 1168 of file CodeGenerator.cs.

1169 {
1170 if (target == source)
1171 {
1172 return;
1173 }
1174 if (target.IsValueType)
1175 {
1176 if (source.IsValueType)
1177 {
1178 OpCode convOpCode = GetConvOpCode(Type.GetTypeCode(target));
1179 if (convOpCode.Equals(OpCodes.Nop))
1180 {
1181 throw new CodeGeneratorConversionException(source, target, isAddress, "NoConversionPossibleTo");
1182 }
1184 return;
1185 }
1186 if (!source.IsAssignableFrom(target))
1187 {
1188 throw new CodeGeneratorConversionException(source, target, isAddress, "IsNotAssignableFrom");
1189 }
1190 Unbox(target);
1191 if (!isAddress)
1192 {
1193 Ldobj(target);
1194 }
1195 }
1196 else if (target.IsAssignableFrom(source))
1197 {
1198 if (source.IsValueType)
1199 {
1200 if (isAddress)
1201 {
1202 Ldobj(source);
1203 }
1204 Box(source);
1205 }
1206 }
1207 else if (source.IsAssignableFrom(target))
1208 {
1209 Castclass(target);
1210 }
1211 else
1212 {
1213 if (!target.IsInterface && !source.IsInterface)
1214 {
1215 throw new CodeGeneratorConversionException(source, target, isAddress, "IsNotAssignableFrom");
1216 }
1217 Castclass(target);
1218 }
1219 }
virtual void Emit(OpCode opcode)
static readonly OpCode Nop
Definition OpCodes.cs:5
OpCode GetConvOpCode(TypeCode typeCode)

References System.Xml.Serialization.CodeGenerator._ilGen, System.Reflection.Emit.Box, System.Reflection.Emit.Castclass, System.Reflection.Emit.ILGenerator.Emit(), System.Xml.Serialization.CodeGenerator.GetConvOpCode(), System.Type.GetTypeCode(), System.Type.IsAssignableFrom(), System.Type.IsInterface, System.Type.IsValueType, System.Reflection.Emit.Ldobj, System.Reflection.Emit.OpCodes.Nop, System.source, and System.Reflection.Emit.Unbox.

Referenced by System.Xml.Serialization.CodeGenerator.ConvertAddress(), and System.Xml.Serialization.CodeGenerator.ConvertValue().