Exemplo n.º 1
0
 public static void Serialize(List <int> list, Core.Utils.MyBinaryWriter writer, List <int> lastList = null,
                              bool writeAll = false)
 {
     if (list == null || list.Count == 0)
     {
         writer.Write((short)0);
     }
     else
     {
         writer.Write((short)list.Count);
         foreach (var i in list)
         {
             writer.Write(i);
         }
     }
 }
Exemplo n.º 2
0
 public void Write(string data, Core.Utils.MyBinaryWriter writer)
 {
     if (data == null)
     {
         Logger.InfoFormat("StringSerializer String is Null");
         data = string.Empty;
     }
     writer.Write(data);
 }
Exemplo n.º 3
0
        public static void Serialize <T>(T[] currArr, Core.Utils.MyBinaryWriter writer, T[] lastArr = null,
                                         bool writeAll = false) where T : class, IPatchClass <T>, new()
        {
            BitArrayWrapper bitArray  = GetDiffBitArray(lastArr, currArr, writeAll);
            var             count     = currArr == null ? 0 : currArr.Length;
            var             lastCount = lastArr == null ? 0 : lastArr.Length;

            writer.Write(bitArray);

            for (int i = 0; i < count; i++)
            {
                if (bitArray[i] == false)
                {
                    continue;
                }
                var last = i >= lastCount || writeAll ? default(T) : lastArr[i];
                Serialize(currArr[i], last, writer);
            }
            bitArray.ReleaseReference();
        }
Exemplo n.º 4
0
        public static void Serialize <T>(List <T> list, Core.Utils.MyBinaryWriter writer, List <T> lastList = null,
                                         bool writeAll = false) where T : IPatchClass <T>, new()
        {
            BitArrayWrapper bitArray  = GetDiffBitArray(lastList, list, writeAll);
            var             count     = list == null ? 0 : list.Count;
            var             lastCount = lastList == null ? 0 : lastList.Count;

            writer.Write(bitArray);

            for (int i = 0; i < count; i++)
            {
                if (bitArray[i] == false)
                {
                    continue;
                }
                var last = i >= lastCount || writeAll ? default(T) : lastList[i];
                PatchPropertySerializer.Write(list[i], last, writer);
            }

            bitArray.ReleaseReference();
        }
Exemplo n.º 5
0
 public void Write(Vector3 data, Core.Utils.MyBinaryWriter writer)
 {
     writer.Write(data.x);
     writer.Write(data.y);
     writer.Write(data.z);
 }
Exemplo n.º 6
0
 public void Write(InterruptData data, Core.Utils.MyBinaryWriter writer)
 {
     writer.Write(data.cmdType);
     writer.Write(data.hasValue);
     writer.Write(data.state);
 }
Exemplo n.º 7
0
 public void Write(uint data, Core.Utils.MyBinaryWriter writer)
 {
     writer.Write(data);
 }