composeBinary() private static méthode

private static composeBinary ( object obj ) : byte[]
obj object
Résultat byte[]
        private static byte[] composeBinaryArray(List <object> objects)
        {
            List <byte> byteList1 = new List <byte>();
            List <byte> byteList2 = new List <byte>();
            List <int>  intList   = new List <int>();

            for (int index = objects.Count - 1; index >= 0; --index)
            {
                Plist.composeBinary(objects[index]);
                Plist.offsetTable.Add(Plist.objectTable.Count);
                intList.Add(Plist.refCount);
                --Plist.refCount;
            }
            if (objects.Count < 15)
            {
                byteList2.Add(Convert.ToByte(160 | (int)Convert.ToByte(objects.Count)));
            }
            else
            {
                byteList2.Add((byte)175);
                byteList2.AddRange((IEnumerable <byte>)Plist.writeBinaryInteger(objects.Count, false));
            }
            foreach (int num in intList)
            {
                byte[] numArray = Plist.RegulateNullBytes(BitConverter.GetBytes(num), Plist.objRefSize);
                Array.Reverse((Array)numArray);
                byteList1.InsertRange(0, (IEnumerable <byte>)numArray);
            }
            byteList1.InsertRange(0, (IEnumerable <byte>)byteList2);
            Plist.objectTable.InsertRange(0, (IEnumerable <byte>)byteList1);
            return(byteList1.ToArray());
        }
Exemple #2
0
        // Token: 0x06000116 RID: 278 RVA: 0x00007790 File Offset: 0x00005990
        private static byte[] composeBinaryArray(List <object> objects)
        {
            List <byte> list  = new List <byte>();
            List <byte> list2 = new List <byte>();
            List <int>  list3 = new List <int>();

            for (int i = objects.Count - 1; i >= 0; i--)
            {
                Plist.composeBinary(objects[i]);
                Plist.offsetTable.Add(Plist.objectTable.Count);
                list3.Add(Plist.refCount);
                Plist.refCount--;
            }
            if (objects.Count < 15)
            {
                list2.Add(Convert.ToByte((int)(160 | Convert.ToByte(objects.Count))));
            }
            else
            {
                list2.Add(175);
                list2.AddRange(Plist.writeBinaryInteger(objects.Count, false));
            }
            foreach (int current in list3)
            {
                byte[] array = Plist.RegulateNullBytes(BitConverter.GetBytes(current), Plist.objRefSize);
                Array.Reverse(array);
                list.InsertRange(0, array);
            }
            list.InsertRange(0, list2);
            Plist.objectTable.InsertRange(0, list);
            return(list.ToArray());
        }
        private static byte[] writeBinaryDictionary(Dictionary <string, object> dictionary)
        {
            List <byte> byteList1 = new List <byte>();
            List <byte> byteList2 = new List <byte>();
            List <int>  intList   = new List <int>();

            for (int index = dictionary.Count - 1; index >= 0; --index)
            {
                object[] array = new object[dictionary.Count];
                dictionary.Values.CopyTo(array, 0);
                Plist.composeBinary(array[index]);
                Plist.offsetTable.Add(Plist.objectTable.Count);
                intList.Add(Plist.refCount);
                --Plist.refCount;
            }
            for (int index = dictionary.Count - 1; index >= 0; --index)
            {
                string[] array = new string[dictionary.Count];
                dictionary.Keys.CopyTo(array, 0);
                Plist.composeBinary((object)array[index]);
                Plist.offsetTable.Add(Plist.objectTable.Count);
                intList.Add(Plist.refCount);
                --Plist.refCount;
            }
            if (dictionary.Count < 15)
            {
                byteList2.Add(Convert.ToByte(208 | (int)Convert.ToByte(dictionary.Count)));
            }
            else
            {
                byteList2.Add((byte)223);
                byteList2.AddRange((IEnumerable <byte>)Plist.writeBinaryInteger(dictionary.Count, false));
            }
            foreach (int num in intList)
            {
                byte[] numArray = Plist.RegulateNullBytes(BitConverter.GetBytes(num), Plist.objRefSize);
                Array.Reverse((Array)numArray);
                byteList1.InsertRange(0, (IEnumerable <byte>)numArray);
            }
            byteList1.InsertRange(0, (IEnumerable <byte>)byteList2);
            Plist.objectTable.InsertRange(0, (IEnumerable <byte>)byteList1);
            return(byteList1.ToArray());
        }
Exemple #4
0
        // Token: 0x06000115 RID: 277 RVA: 0x000075D8 File Offset: 0x000057D8
        private static byte[] writeBinaryDictionary(Dictionary <string, object> dictionary)
        {
            List <byte> list  = new List <byte>();
            List <byte> list2 = new List <byte>();
            List <int>  list3 = new List <int>();

            for (int i = dictionary.Count - 1; i >= 0; i--)
            {
                object[] array = new object[dictionary.Count];
                dictionary.Values.CopyTo(array, 0);
                Plist.composeBinary(array[i]);
                Plist.offsetTable.Add(Plist.objectTable.Count);
                list3.Add(Plist.refCount);
                Plist.refCount--;
            }
            for (int i = dictionary.Count - 1; i >= 0; i--)
            {
                string[] array2 = new string[dictionary.Count];
                dictionary.Keys.CopyTo(array2, 0);
                Plist.composeBinary(array2[i]);
                Plist.offsetTable.Add(Plist.objectTable.Count);
                list3.Add(Plist.refCount);
                Plist.refCount--;
            }
            if (dictionary.Count < 15)
            {
                list2.Add(Convert.ToByte((int)(208 | Convert.ToByte(dictionary.Count))));
            }
            else
            {
                list2.Add(223);
                list2.AddRange(Plist.writeBinaryInteger(dictionary.Count, false));
            }
            foreach (int current in list3)
            {
                byte[] array3 = Plist.RegulateNullBytes(BitConverter.GetBytes(current), Plist.objRefSize);
                Array.Reverse(array3);
                list.InsertRange(0, array3);
            }
            list.InsertRange(0, list2);
            Plist.objectTable.InsertRange(0, list);
            return(list.ToArray());
        }
        public static byte[] writeBinary(object value)
        {
            Plist.offsetTable.Clear();
            Plist.objectTable.Clear();
            Plist.refCount          = 0;
            Plist.objRefSize        = 0;
            Plist.offsetByteSize    = 0;
            Plist.offsetTableOffset = 0L;
            int num = Plist.countObject(value) - 1;

            Plist.refCount   = num;
            Plist.objRefSize = Plist.RegulateNullBytes(BitConverter.GetBytes(Plist.refCount)).Length;
            Plist.composeBinary(value);
            Plist.writeBinaryString("bplist00", false);
            Plist.offsetTableOffset = (long)Plist.objectTable.Count;
            Plist.offsetTable.Add(Plist.objectTable.Count - 8);
            Plist.offsetByteSize = Plist.RegulateNullBytes(BitConverter.GetBytes(Plist.offsetTable[Plist.offsetTable.Count - 1])).Length;
            List <byte> byteList = new List <byte>();

            Plist.offsetTable.Reverse();
            for (int index = 0; index < Plist.offsetTable.Count; ++index)
            {
                Plist.offsetTable[index] = Plist.objectTable.Count - Plist.offsetTable[index];
                byte[] numArray = Plist.RegulateNullBytes(BitConverter.GetBytes(Plist.offsetTable[index]), Plist.offsetByteSize);
                Array.Reverse((Array)numArray);
                byteList.AddRange((IEnumerable <byte>)numArray);
            }
            Plist.objectTable.AddRange((IEnumerable <byte>)byteList);
            Plist.objectTable.AddRange((IEnumerable <byte>) new byte[6]);
            Plist.objectTable.Add(Convert.ToByte(Plist.offsetByteSize));
            Plist.objectTable.Add(Convert.ToByte(Plist.objRefSize));
            byte[] bytes1 = BitConverter.GetBytes((long)num + 1L);
            Array.Reverse((Array)bytes1);
            Plist.objectTable.AddRange((IEnumerable <byte>)bytes1);
            Plist.objectTable.AddRange((IEnumerable <byte>)BitConverter.GetBytes(0L));
            byte[] bytes2 = BitConverter.GetBytes(Plist.offsetTableOffset);
            Array.Reverse((Array)bytes2);
            Plist.objectTable.AddRange((IEnumerable <byte>)bytes2);
            return(Plist.objectTable.ToArray());
        }
Exemple #6
0
        // Token: 0x0600010B RID: 267 RVA: 0x00006C84 File Offset: 0x00004E84
        public static byte[] writeBinary(object value)
        {
            Plist.offsetTable.Clear();
            Plist.objectTable.Clear();
            Plist.refCount          = 0;
            Plist.objRefSize        = 0;
            Plist.offsetByteSize    = 0;
            Plist.offsetTableOffset = 0L;
            int num = Plist.countObject(value) - 1;

            Plist.refCount   = num;
            Plist.objRefSize = Plist.RegulateNullBytes(BitConverter.GetBytes(Plist.refCount)).Length;
            Plist.composeBinary(value);
            Plist.writeBinaryString("bplist00", false);
            Plist.offsetTableOffset = (long)Plist.objectTable.Count;
            Plist.offsetTable.Add(Plist.objectTable.Count - 8);
            Plist.offsetByteSize = Plist.RegulateNullBytes(BitConverter.GetBytes(Plist.offsetTable[Plist.offsetTable.Count - 1])).Length;
            List <byte> list = new List <byte>();

            Plist.offsetTable.Reverse();
            for (int i = 0; i < Plist.offsetTable.Count; i++)
            {
                Plist.offsetTable[i] = Plist.objectTable.Count - Plist.offsetTable[i];
                byte[] array = Plist.RegulateNullBytes(BitConverter.GetBytes(Plist.offsetTable[i]), Plist.offsetByteSize);
                Array.Reverse(array);
                list.AddRange(array);
            }
            Plist.objectTable.AddRange(list);
            Plist.objectTable.AddRange(new byte[6]);
            Plist.objectTable.Add(Convert.ToByte(Plist.offsetByteSize));
            Plist.objectTable.Add(Convert.ToByte(Plist.objRefSize));
            byte[] bytes = BitConverter.GetBytes((long)num + 1L);
            Array.Reverse(bytes);
            Plist.objectTable.AddRange(bytes);
            Plist.objectTable.AddRange(BitConverter.GetBytes(0L));
            bytes = BitConverter.GetBytes(Plist.offsetTableOffset);
            Array.Reverse(bytes);
            Plist.objectTable.AddRange(bytes);
            return(Plist.objectTable.ToArray());
        }