static Array ReadObjectArray(this BinaryReader reader, BinaryUtility.TypeCodes elementTypeCode) { Type elementType = BinaryUtility.ToType(elementTypeCode) ?? reader.ReadType(); int length = reader.ReadInt32(); var array = Array.CreateInstance(elementType, length); for (int i = 0; i < length; i++) { array.SetValue(reader.ReadObject(), i); } return(array); }
static IList ReadObjectList(this BinaryReader reader, BinaryUtility.TypeCodes elementTypeCode) { Type elementType = BinaryUtility.ToType(elementTypeCode) ?? reader.ReadType(); int count = reader.ReadInt32(); var list = (IList)Activator.CreateInstance(typeof(List <>).MakeGenericType(elementType), count); for (int i = 0; i < count; i++) { list.Add(reader.ReadObject()); } return(list); }
static object ReadOther(this BinaryReader reader) { ushort serializerId = reader.ReadUInt16(); var serializer = BinaryUtility.GetSerializer(BinaryUtility.ToType()); if (serializer == null) { return(null); } else { return(serializer.Deserialize(reader)); } }