public object Deserialize( StreamReader streamReader, SerializationContext serializationContext, PropertyMetaData propertyMetaData = null) { int arrayLength; if (propertyMetaData.Options.SerializeSize != ArraySizeType.NoSerialization) { var arraySizeSerializer = new ArraySizeSerializer(propertyMetaData.Options.SerializeSize); arrayLength = (int)arraySizeSerializer.Deserialize(streamReader, serializationContext, propertyMetaData); } else { arrayLength = propertyMetaData.Options.FixedSizeLength; } var array = Array.CreateInstance(this.typeSerializer.Type, arrayLength); for (var i = 0; i < arrayLength; i++) { var element = this.typeSerializer.Deserialize(streamReader, serializationContext, propertyMetaData); array.SetValue(element, i); } return(array); }
public object Deserialize( StreamReader streamReader, SerializationContext serializationContext, PropertyMetaData propertyMetaData = null) { int arrayLength; var array = Array.CreateInstance(this.typeSerializer.Type, 0); if (propertyMetaData.Options.SerializeSize == ArraySizeType.NullTerminated) { List <object> temp = new List <object>(); int check = 0; do { check = streamReader.ReadInt32(); if (check != 0) { streamReader.Position -= 4; var element = this.typeSerializer.Deserialize( streamReader, serializationContext, propertyMetaData); temp.Add(element); } }while (check != 0); } else { if (propertyMetaData.Options.SerializeSize != ArraySizeType.NoSerialization) { var arraySizeSerializer = new ArraySizeSerializer(propertyMetaData.Options.SerializeSize); arrayLength = (int)arraySizeSerializer.Deserialize(streamReader, serializationContext, propertyMetaData); } else { arrayLength = propertyMetaData.Options.FixedSizeLength; } array = Array.CreateInstance(this.typeSerializer.Type, arrayLength); for (var i = 0; i < arrayLength; i++) { var element = this.typeSerializer.Deserialize(streamReader, serializationContext, propertyMetaData); array.SetValue(element, i); } } return(array); }
public object Deserialize( StreamReader streamReader, SerializationContext serializationContext, PropertyMetaData propertyMetaData = null) { int length; if (propertyMetaData.Options.SerializeSize == ArraySizeType.NoSerialization) { length = propertyMetaData.Options.FixedSizeLength; } else { var arraySizeSerializer = new ArraySizeSerializer(propertyMetaData.Options.SerializeSize); length = (int) arraySizeSerializer.Deserialize( streamReader, serializationContext, propertyMetaData: propertyMetaData); } return streamReader.ReadString(length); }
public object Deserialize( StreamReader streamReader, SerializationContext serializationContext, PropertyMetaData propertyMetaData = null) { int length; if (propertyMetaData.Options.SerializeSize == ArraySizeType.NoSerialization) { length = propertyMetaData.Options.FixedSizeLength; } else { var arraySizeSerializer = new ArraySizeSerializer(propertyMetaData.Options.SerializeSize); length = (int) arraySizeSerializer.Deserialize( streamReader, serializationContext, propertyMetaData: propertyMetaData); } return(streamReader.ReadString(length)); }
public object Deserialize( StreamReader streamReader, SerializationContext serializationContext, PropertyMetaData propertyMetaData = null) { int arrayLength; var array = Array.CreateInstance(this.typeSerializer.Type, 0); if (propertyMetaData.Options.SerializeSize == ArraySizeType.NullTerminated) { List<object> temp = new List<object>(); int check = 0; do { check = streamReader.ReadInt32(); if (check != 0) { streamReader.Position -= 4; var element = this.typeSerializer.Deserialize( streamReader, serializationContext, propertyMetaData); temp.Add(element); } } while (check != 0); } else { if (propertyMetaData.Options.SerializeSize != ArraySizeType.NoSerialization) { var arraySizeSerializer = new ArraySizeSerializer(propertyMetaData.Options.SerializeSize); arrayLength = (int)arraySizeSerializer.Deserialize(streamReader, serializationContext, propertyMetaData); } else { arrayLength = propertyMetaData.Options.FixedSizeLength; } array = Array.CreateInstance(this.typeSerializer.Type, arrayLength); for (var i = 0; i < arrayLength; i++) { var element = this.typeSerializer.Deserialize(streamReader, serializationContext, propertyMetaData); array.SetValue(element, i); } } return array; }