示例#1
0
        public static PinnedObject CreatePinnedObject(byte[] bytes)
        {
            if (bytes == null)
                return PinnedObject.Null;

            var bytesPinned = new PinnedObject(bytes);

            var byteArray = new NativeArray
            {
                Length = bytes.Length,
                Items = bytesPinned.Ptr
            };

            return new PinnedObject(byteArray, new[] { bytesPinned });
        }
示例#2
0
        public static PinnedObject CreatePinnedObject(byte[] bytes)
        {
            if (bytes == null)
            {
                return(PinnedObject.Null);
            }

            var bytesPinned = new PinnedObject(bytes);

            var byteArray = new NativeArray
            {
                Length = bytes.Length,
                Items  = bytesPinned.Ptr
            };

            return(new PinnedObject(byteArray, new[] { bytesPinned }));
        }
示例#3
0
        public static PinnedObject CreatePinnedObject(IEnumerable<byte[]> arrays)
        {
            if (arrays == null)
                return PinnedObject.Null;

            var pinnedArrays = arrays.Select(CreatePinnedObject).ToList();

            var arrayPtrs = pinnedArrays.Select(x => x.Ptr).ToArray();
            var pinnedArrayPtrs = new PinnedObject(arrayPtrs, pinnedArrays);

            var array = new NativeArray
            {
                Length = pinnedArrays.Count,
                Items = pinnedArrayPtrs.Ptr
            };

            return new PinnedObject(array, new[] { pinnedArrayPtrs });
        }
示例#4
0
        public static PinnedObject CreatePinnedObject(IEnumerable <byte[]> arrays)
        {
            if (arrays == null)
            {
                return(PinnedObject.Null);
            }

            var pinnedArrays = arrays.Select(CreatePinnedObject).ToList();

            var arrayPtrs       = pinnedArrays.Select(x => x.Ptr).ToArray();
            var pinnedArrayPtrs = new PinnedObject(arrayPtrs, pinnedArrays);

            var array = new NativeArray
            {
                Length = pinnedArrays.Count,
                Items  = pinnedArrayPtrs.Ptr
            };

            return(new PinnedObject(array, new[] { pinnedArrayPtrs }));
        }