Beispiel #1
0
 public static void AddDouble(ref byte[] dat, Pointer curPointer, double num)
 {
     byte[] bin = BitConverter.GetBytes(num);
     EnsureBufferSize(ref dat, curPointer, bin.Length);
     Util.Copy(bin, 0, dat, curPointer.Advance(bin.Length), bin.Length);
 }
Beispiel #2
0
 public static void AddByte(ref byte[] dat, Pointer p, byte bt)
 {
     EnsureBufferSize(ref dat, p, 1);
     dat[p.Advance(1)] = bt;
 }
Beispiel #3
0
 public static void AddBytes(ref byte[] dat, Pointer curPointer, byte[] bytes)
 {
     AddInt(ref dat, curPointer, bytes.Length);
     EnsureBufferSize(ref dat, curPointer, bytes.Length);
     Util.Copy(bytes, 0, dat, curPointer.Advance(bytes.Length), bytes.Length);
 }
Beispiel #4
0
 public static uint GetUInt(byte[] dat, Pointer p)
 {
     uint num = BitConverter.ToUInt32(dat, p.Advance(4));
     return num;
 }
Beispiel #5
0
 public static void AddBool(ref byte[] dat, Pointer curPointer, bool val)
 {
     byte[] bin = BitConverter.GetBytes(val);
     EnsureBufferSize(ref dat, curPointer, bin.Length);
     Util.Copy(bin, 0, dat, curPointer.Advance(bin.Length), bin.Length);
 }
Beispiel #6
0
 public static float GetSingle(byte[] dat, Pointer p)
 {
     float num = BitConverter.ToSingle(dat, p.Advance(4));
     return num;
 }
Beispiel #7
0
 public static string GetString(byte[] dat, Pointer p)
 {
     int wordsLen = BitConverter.ToInt32(dat, p.Advance(4));
     string words = System.Text.Encoding.UTF8.GetString(dat, p.Advance(wordsLen), wordsLen);
     return words;
 }
Beispiel #8
0
 public static long GetLong(byte[] dat, Pointer p)
 {
     long num = BitConverter.ToInt64(dat, p.Advance(8));
     return num;
 }
Beispiel #9
0
 public static short GetShort(byte[] dat, Pointer p)
 {
     short num = BitConverter.ToInt16(dat, p.Advance(2));
     return num;
 }
Beispiel #10
0
 public static double GetDouble(byte[] dat, Pointer p)
 {
     double num = BitConverter.ToDouble(dat, p.Advance(8));
     return num;
 }
Beispiel #11
0
        /// <summary>
        /// Retr
        /// </summary>
        /// <param name="dat"></param>
        /// <param name="curPointer"></param>
        /// <returns></returns>
        public static byte[] GetBytes(byte[] dat, Pointer curPointer)
        {
            int len = GetInt(dat, curPointer);
            byte[] bytes = new byte[len];
            Util.Copy(dat, curPointer.Advance(len), bytes, 0, len);

            return bytes;
        }
Beispiel #12
0
 public static byte GetByte(byte[] dat, Pointer p)
 {
     return dat[p.Advance(1)];
 }
Beispiel #13
0
 public static bool GetBool(byte[] dat, Pointer p)
 {
     bool val = BitConverter.ToBoolean(dat, p.Advance(1));
     return val;
 }
Beispiel #14
0
        public static void AddString(ref byte[] dat, Pointer curPointer, string words)
        {
            if (words == null) words = "";
            byte[] bin = System.Text.Encoding.UTF8.GetBytes(words);
            AddInt(ref dat, curPointer, bin.Length);

            EnsureBufferSize(ref dat, curPointer, bin.Length);
            Util.Copy(bin, 0, dat, curPointer.Advance(bin.Length), bin.Length);
        }