Exemplo n.º 1
0
        public static unsafe void WriteArray <T>(IntPtr destination, T[] buffer, int index, int count)
            where T : struct
        {
            uint elementSize = (uint)SizeOf <T>();

            if (buffer == null)
            {
                throw new ArgumentNullException("buffer");
            }
            if (count < 0)
            {
                throw new ArgumentOutOfRangeException("count");
            }
            if (index < 0)
            {
                throw new ArgumentOutOfRangeException("index");
            }
            if (buffer.Length - index < count)
            {
                throw new ArgumentException("Invalid offset into array specified by index and count");
            }

            void *ptr = destination.ToPointer();
            byte *p   = (byte *)FastStructure.GetPtr <T>(ref buffer[0]);

            Buffer.MemoryCopy(p + (index * elementSize), ptr, elementSize * count, elementSize * count);
        }
Exemplo n.º 2
0
 public static unsafe void *GetPtr <T>(ref T structure)
     where T : struct
 {
     return(FastStructure <T> .GetPtr(ref structure));
 }