public void Pack(Packer packer, object obj) { var buffer = (ME.ECS.Collections.IBufferArray)obj; var arr = buffer.GetArray(); if (arr == null) { packer.WriteByte((byte)TypeValue.Null); var int32 = new Int32Serializer(); int32.Pack(packer, packer.GetMetaTypeId(obj.GetType().GenericTypeArguments[0])); } else { packer.WriteByte((byte)TypeValue.ObjectArray); var length = buffer.Count; var int32 = new Int32Serializer(); int32.Pack(packer, length); int32.Pack(packer, packer.GetMetaTypeId(arr.GetType().GetElementType())); for (var i = 0; i < length; ++i) { packer.PackInternal(arr.GetValue(i)); } } }