public object Unpack(Packer packer) { var typeId = Int32Serializer.UnpackDirect(packer); var rootType = packer.GetMetaType(typeId); return(this.Unpack(packer, rootType)); }
public object Unpack(Packer packer) { var type = packer.GetMetaType(Int32Serializer.UnpackDirect(packer)); var typeValue = packer.GetMetaType(Int32Serializer.UnpackDirect(packer)); var typeProvider = packer.GetMetaType(Int32Serializer.UnpackDirect(packer)); var sentinelType = type.MakeGenericType(typeValue, typeProvider); var poolClassType = typeof(PoolClass <>).MakeGenericType(sentinelType); var spawnMethod = poolClassType.GetMethod("Spawn", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static); var sentinel = (IDisposeSentinel)spawnMethod.Invoke(null, null); sentinel.SetData(packer.UnpackInternal()); sentinel.SetTick(Int64Serializer.UnpackDirect(packer)); return(sentinel); }
public object Unpack(Packer packer) { var length = Int32Serializer.UnpackDirect(packer); var typeIdValue = Int32Serializer.UnpackDirect(packer); var typeValue = packer.GetMetaType(typeIdValue); var type = packer.GetMetaType(Int32Serializer.UnpackDirect(packer)); var t = type.MakeGenericType(typeValue); var dict = (ME.ECS.Collections.IDictionaryInt)System.Activator.CreateInstance(t); for (int i = 0; i < length; ++i) { dict.Add(packer.UnpackInternal(), packer.UnpackInternal()); } return(dict); }
public object Unpack(Packer packer) { var length = Int32Serializer.UnpackDirect(packer); var isArray = packer.ReadByte(); var typeId = Int32Serializer.UnpackDirect(packer); var typeIn = packer.GetMetaType(typeId); IList arr = null; if (isArray == 2) { var rank = Int32Serializer.UnpackDirect(packer); if (rank > 1) { var lengthArray = new int[rank]; for (int j = 0; j < rank; ++j) { lengthArray[j] = Int32Serializer.UnpackDirect(packer); } var arrData = System.Array.CreateInstance(typeIn, lengthArray); arr = arrData; void WrapDimension(int[] ids, int currentDimension) { if (currentDimension == rank) { arrData.SetValue(packer.UnpackInternal(), ids); } else { for (int i = 0, len = arrData.GetLength(currentDimension); i < len; i++) { ids[currentDimension] = i; WrapDimension(ids, currentDimension + 1); } } } WrapDimension(new int[rank], 0); } } else if (isArray == 1) { arr = System.Array.CreateInstance(typeIn, length); for (int i = 0; i < length; ++i) { arr[i] = packer.UnpackInternal(); } } else { var type = packer.GetMetaType(Int32Serializer.UnpackDirect(packer)); var t = type.MakeGenericType(typeIn); arr = (IList)System.Activator.CreateInstance(t); for (int i = 0; i < length; ++i) { arr.Add(packer.UnpackInternal()); } } return(arr); }