public override object OnRead(ByteObjectReader reader, Type defaultItemType) { var itemType = reader.Type(defaultItemType); var rank = reader.Int(); var lengths = new int[rank]; for (int i = 0; i < rank; i++) lengths[i] = reader.Int(); var array = Array.CreateInstance(itemType, lengths); var indexes = new int[rank]; DimensionalReadResoursy(reader, array, itemType, 0, indexes); return array; }
public override object OnRead(ByteObjectReader reader, Type defaultItemType) { var itemType = reader.Type(defaultItemType); var length = reader.Int(); var array = Array.CreateInstance(itemType, length); for (int i = 0; i < length; i++) { var item = reader.Complex(itemType); array.SetValue(item, i); } return array; }
public override object OnRead(ByteObjectReader reader, Type defaultItemType) { var type = reader.Byte(); if (type == IsDefinition) { var handleIndex = reader.position - sizeof(byte); var classType = reader.Type(defaultItemType); var rule = ByteUtils.GetRule(classType); if (rule != null) { return rule.OnReadInternal(reader); } else { var obj = Activator.CreateInstance(classType); //todo reader.classHashtable[handleIndex] = obj; var fields = usedFields.GetUnical(classType); if (fields == null) fields = ByteUtils.GetSerializeFields(classType); var fieldCount = reader.Ushort(); for (int i = 0; i < fieldCount; i++) { var fieldName = reader.String(); var value = reader.Complex(null); var field = fields.FirstOrDefault(x => x.Name == fieldName); if (field != null) { field.SetValue(obj, value); } } return obj; } } if (type == IsGoto) { var handleIndex = reader.Int(); return reader.classHashtable[handleIndex]; } throw new Exception("Wtf?"); }
public override object OnRead(ByteObjectReader reader, Type defaultItemType) { var instanceId = reader.Int(); var unityObj = reader.unityHashtable[instanceId]; return unityObj; }
public override object OnRead(ByteObjectReader reader, Type defaultItemType) { return reader.Int(); }