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

◆ ReadItemOfPrimitiveType()

object System.Runtime.Serialization.ReflectionReader.ReadItemOfPrimitiveType ( XmlReaderDelegator xmlReader,
XmlObjectSerializerReadContext context,
Type type,
string name,
string ns,
PrimitiveDataContract primitiveContract,
int nullables )
inlineprivateinherited

Definition at line 226 of file ReflectionReader.cs.

227 {
228 context.ReadAttributes(xmlReader);
229 string text = context.ReadIfNullOrRef(xmlReader, type, DataContract.IsTypeSerializable(type));
230 bool isValueType = type.IsValueType;
231 if (text != null)
232 {
233 if (text.Length == 0)
234 {
235 text = context.GetObjectId();
236 if (!string.IsNullOrEmpty(text) && isValueType)
237 {
238 throw new SerializationException(System.SR.Format(System.SR.ValueTypeCannotHaveId, DataContract.GetClrTypeFullName(type)));
239 }
240 if (primitiveContract != null && primitiveContract.UnderlyingType != Globals.TypeOfObject)
241 {
242 return primitiveContract.ReadXmlValue(xmlReader, context);
243 }
244 return ReflectionInternalDeserialize(xmlReader, context, null, type, name, ns);
245 }
246 if (isValueType)
247 {
248 throw new SerializationException(System.SR.Format(System.SR.ValueTypeCannotHaveRef, DataContract.GetClrTypeFullName(type)));
249 }
250 return context.GetExistingObject(text, type, name, ns);
251 }
252 if (isValueType && nullables == 0)
253 {
254 throw new SerializationException(System.SR.Format(System.SR.ValueTypeCannotBeNull, DataContract.GetClrTypeFullName(type)));
255 }
256 return null;
257 }
object ReflectionInternalDeserialize(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context, CollectionDataContract collectionContract, Type type, string name, string ns)
static string ValueTypeCannotHaveId
Definition SR.cs:302
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string ValueTypeCannotHaveRef
Definition SR.cs:306
static string ValueTypeCannotBeNull
Definition SR.cs:298
Definition SR.cs:7

References System.SR.Format(), System.Runtime.Serialization.DataContract.GetClrTypeFullName(), System.Runtime.Serialization.XmlObjectSerializerReadContext.GetExistingObject(), System.Runtime.Serialization.XmlObjectSerializerReadContext.GetObjectId(), System.Runtime.Serialization.DataContract.IsTypeSerializable(), System.Runtime.Serialization.XmlObjectSerializerReadContext.ReadAttributes(), System.Runtime.Serialization.XmlObjectSerializerReadContext.ReadIfNullOrRef(), System.text, System.type, System.Runtime.Serialization.Globals.TypeOfObject, System.SR.ValueTypeCannotBeNull, System.SR.ValueTypeCannotHaveId, and System.SR.ValueTypeCannotHaveRef.