コード例 #1
0
ファイル: DB2.cs プロジェクト: wzx1598763/wowedit_unity
        public ulong ReadUInt64(int numBits)
        {
            ulong result = FastStruct <ulong> .ArrayToStructure(ref m_array[m_readOffset + (m_readPos >> 3)]) << (64 - numBits - (m_readPos & 7)) >> (64 - numBits);

            m_readPos += numBits;
            return(result);
        }
コード例 #2
0
ファイル: DB2.cs プロジェクト: wzx1598763/wowedit_unity
        public uint ReadUInt32(int numBits)
        {
            uint result = FastStruct <uint> .ArrayToStructure(ref m_array[m_readOffset + (m_readPos >> 3)]) << (32 - numBits - (m_readPos & 7)) >> (32 - numBits);

            m_readPos += numBits;
            return(result);
        }
コード例 #3
0
    public static T[] ReadArray <T>(this BinaryReader reader, int size) where T : struct
    {
        int numBytes = Marshal.SizeOf <T>() * size;

        byte[] result = reader.ReadBytes(numBytes);

        return(FastStruct <T> .ReadArray(result));
    }
コード例 #4
0
 public T GetValue <T>() where T : struct
 {
     unsafe
     {
         fixed(byte *ptr = Value)
         return(FastStruct <T> .ArrayToStructure(ref ptr[0]));
     }
 }
コード例 #5
0
    public T Read <T>(MemoryStream ms) where T : struct
    {
        int size = FastStruct <T> .Size;

        byte[] result = new byte[size];
        ms.Read(result, 0, size);
        return(FastStruct <T> .ArrayToStructure(result));
    }
コード例 #6
0
    public T[] ReadArray <T>(MemoryStream ms, int size) where T : struct
    {
        int numBytes = Marshal.SizeOf <T>() * size;

        byte[] result = new byte[numBytes];
        ms.Read(result, 0, numBytes);

        return(FastStruct <T> .ReadArray(result));
    }
コード例 #7
0
        public static T[] ReadArray <T>(this BinaryReader reader) where T : struct
        {
            int numBytes = (int)reader.ReadInt64();

            byte[] result = reader.ReadBytes(numBytes);

            reader.BaseStream.Position += (0 - numBytes) & 0x07;
            return(FastStruct <T> .ReadArray(result));
        }
コード例 #8
0
    public T[] ReadArray <T>(MemoryStream ms) where T : struct
    {
        int numBytes = (int)ReadInt64(ms);

        byte[] result = new byte[numBytes];
        ms.Read(result, 0, numBytes);

        ms.Position += (0 - numBytes) & 0x07;
        return(FastStruct <T> .ReadArray(result));
    }
コード例 #9
0
        /// <summary>
        /// Read array of structs from a reader
        /// </summary>
        /// <param name="reader">Target reader</param>
        /// <param name="count">Count</param>
        /// <typeparam name="T">Struct to read</typeparam>
        /// <returns>Stuct array</returns>
        public static T[] ReadArray <T>(this BinaryReader reader, int count) where T : struct
        {
            if (count == 0)
            {
                return(new T[0]);
            }

            int numBytes = FastStruct <T> .Size * count;

            byte[] result = reader.ReadBytes(numBytes);

            return(FastStruct <T> .ReadArray(result));
        }
コード例 #10
0
    public static T Read <T>(this BinaryReader reader) where T : struct
    {
        byte[] result = reader.ReadBytes(FastStruct <T> .Size);

        return(FastStruct <T> .ArrayToStructure(result));
    }
コード例 #11
0
 public void Parse(byte[] bytes)
 {
     Header = FastStruct <Structure> .ArrayToStructure(bytes);
 }
コード例 #12
0
 /// <summary>
 /// Write an array of structs to a BinaryWriter
 /// </summary>
 /// <param name="writer">Target write</param>
 /// <param name="struct">Struct array to write</param>
 /// <typeparam name="T">Struct type</typeparam>
 public static void WriteStructArray <T>(this BinaryWriter writer, T[] @struct) where T : struct
 {
     writer.Write(FastStruct <T> .WriteArray(@struct));
 }
コード例 #13
0
 /// <summary>
 /// Write a struct to a BinaryWriter
 /// </summary>
 /// <param name="writer">Target writer</param>
 /// <param name="struct">Struct instance to write</param>
 /// <typeparam name="T">Struct type</typeparam>
 public static void Write <T>(this BinaryWriter writer, T @struct) where T : struct
 {
     writer.Write(FastStruct <T> .StructureToArray(@struct));
 }