public object Unpack(Packer packer)
        {
            int    arrayTypeId = -1;
            int    typeId      = -1;
            object p1          = null;
            object p2          = null;

            var type = packer.ReadByte();

            if (type == (byte)TypeValue.Null)
            {
                var int32 = new Int32Serializer();
                arrayTypeId = (int)int32.Unpack(packer);
                typeId      = (int)int32.Unpack(packer);
                p1          = null;
                p2          = 0;
            }
            else
            {
                var int32 = new Int32Serializer();
                arrayTypeId = (int)int32.Unpack(packer);
                var length = (int)int32.Unpack(packer);
                typeId = (int)int32.Unpack(packer);
                var elementType = packer.GetMetaType(typeId);

                var poolArrayType = typeof(PoolArray <>).MakeGenericType(elementType);
                var spawnMethod   = poolArrayType.GetMethod("Spawn", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static);
                var bufferArray   = (ME.ECS.Collections.IBufferArray)spawnMethod.Invoke(null, new object[] { length, false });
                var arr           = bufferArray.GetArray();
                for (var i = 0; i < length; ++i)
                {
                    arr.SetValue(packer.UnpackInternal(), i);
                }

                p1 = arr;
                p2 = length;
            }

            var arrayType       = packer.GetMetaType(arrayTypeId);
            var constructedType = arrayType.MakeGenericType(packer.GetMetaType(typeId));
            var instance        = (ME.ECS.Collections.IBufferArray)System.Activator.CreateInstance(constructedType,
                                                                                                   System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic,
                                                                                                   null, new object[] {
                p1, p2, -1,
            }, System.Globalization.CultureInfo.InvariantCulture);

            return(instance);
        }
        public object Unpack(Packer packer)
        {
            int    typeId = -1;
            object p1     = null;
            object p2     = null;

            var type = packer.ReadByte();

            if (type == (byte)TypeValue.Null)
            {
                var int32 = new Int32Serializer();
                typeId = (int)int32.Unpack(packer);
                p1     = null;
                p2     = 0;
            }
            else
            {
                var int32  = new Int32Serializer();
                var length = (int)int32.Unpack(packer);
                typeId = (int)int32.Unpack(packer);
                var elementType = packer.GetMetaType(typeId);

                var arr = System.Array.CreateInstance(elementType, PoolArrayUtilities.GetArrayLengthPot(length));
                for (var i = 0; i < length; ++i)
                {
                    arr.SetValue(packer.UnpackInternal(), i);
                }

                p1 = arr;
                p2 = length;
            }

            var constructedType = typeof(ME.ECS.Collections.BufferArray <>).MakeGenericType(packer.GetMetaType(typeId));
            var instance        = (ME.ECS.Collections.IBufferArray)System.Activator.CreateInstance(constructedType,
                                                                                                   System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic,
                                                                                                   null, new object[] {
                p1, p2
            }, System.Globalization.CultureInfo.InvariantCulture);

            return(instance);
        }