writeBinaryInteger() private static method

private static writeBinaryInteger ( int value, bool write ) : byte[]
value int
write bool
return byte[]
        private static byte[] writeBinaryString(string value, bool head)
        {
            List <byte> byteList1 = new List <byte>();
            List <byte> byteList2 = new List <byte>();

            foreach (char ch in value.ToCharArray())
            {
                byteList1.Add(Convert.ToByte(ch));
            }
            if (head)
            {
                if (value.Length < 15)
                {
                    byteList2.Add(Convert.ToByte(80 | (int)Convert.ToByte(value.Length)));
                }
                else
                {
                    byteList2.Add((byte)95);
                    byteList2.AddRange((IEnumerable <byte>)Plist.writeBinaryInteger(byteList1.Count, false));
                }
            }
            byteList1.InsertRange(0, (IEnumerable <byte>)byteList2);
            Plist.objectTable.InsertRange(0, (IEnumerable <byte>)byteList1);
            return(byteList1.ToArray());
        }
Example #2
0
        // Token: 0x0600011D RID: 285 RVA: 0x00007C80 File Offset: 0x00005E80
        private static byte[] writeBinaryString(string value, bool head)
        {
            List <byte> list  = new List <byte>();
            List <byte> list2 = new List <byte>();

            char[] array = value.ToCharArray();
            for (int i = 0; i < array.Length; i++)
            {
                char value2 = array[i];
                list.Add(Convert.ToByte(value2));
            }
            if (head)
            {
                if (value.Length < 15)
                {
                    list2.Add(Convert.ToByte((int)(80 | Convert.ToByte(value.Length))));
                }
                else
                {
                    list2.Add(95);
                    list2.AddRange(Plist.writeBinaryInteger(list.Count, false));
                }
            }
            list.InsertRange(0, list2);
            Plist.objectTable.InsertRange(0, list);
            return(list.ToArray());
        }
        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());
        }
Example #4
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[] writeBinaryByteArray(byte[] value)
        {
            List <byte> byteList1 = new List <byte>((IEnumerable <byte>)value);
            List <byte> byteList2 = new List <byte>();

            if (value.Length < 15)
            {
                byteList2.Add(Convert.ToByte(64 | (int)Convert.ToByte(value.Length)));
            }
            else
            {
                byteList2.Add((byte)79);
                byteList2.AddRange((IEnumerable <byte>)Plist.writeBinaryInteger(byteList1.Count, false));
            }
            byteList1.InsertRange(0, (IEnumerable <byte>)byteList2);
            Plist.objectTable.InsertRange(0, (IEnumerable <byte>)byteList1);
            return(byteList1.ToArray());
        }
Example #6
0
        // Token: 0x0600011C RID: 284 RVA: 0x00007C0C File Offset: 0x00005E0C
        private static byte[] writeBinaryByteArray(byte[] value)
        {
            List <byte> list  = new List <byte>(value);
            List <byte> list2 = new List <byte>();

            if (value.Length < 15)
            {
                list2.Add(Convert.ToByte((int)(64 | Convert.ToByte(value.Length))));
            }
            else
            {
                list2.Add(79);
                list2.AddRange(Plist.writeBinaryInteger(list.Count, false));
            }
            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());
        }
Example #8
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());
        }
        private static byte[] composeBinary(object obj)
        {
            string s = obj.GetType().ToString();
            // ISSUE: reference to a compiler-generated method
            uint stringHash = (uint.Parse(s));

            if (stringHash <= 1541528931U)
            {
                if (stringHash <= 848225627U)
                {
                    if ((int)stringHash != 347085918)
                    {
                        if ((int)stringHash == 848225627 && s == "System.Double")
                        {
                            return(Plist.writeBinaryDouble((double)obj));
                        }
                    }
                    else if (s == "System.Boolean")
                    {
                        return(Plist.writeBinaryBool((bool)obj));
                    }
                }
                else if ((int)stringHash != 1461188995)
                {
                    if ((int)stringHash == 1541528931 && s == "System.DateTime")
                    {
                        return(Plist.writeBinaryDate((DateTime)obj));
                    }
                }
                else if (s == "System.Collections.Generic.List`1[System.Object]")
                {
                    return(Plist.composeBinaryArray((List <object>)obj));
                }
            }
            else if (stringHash <= 4180476474U)
            {
                if ((int)stringHash != -1520294252)
                {
                    if ((int)stringHash == -114490822 && s == "System.Int32")
                    {
                        return(Plist.writeBinaryInteger((int)obj, true));
                    }
                }
                else if (s == "System.Collections.Generic.Dictionary`2[System.String,System.Object]")
                {
                    return(Plist.writeBinaryDictionary((Dictionary <string, object>)obj));
                }
            }
            else if ((int)stringHash != -93602905)
            {
                if ((int)stringHash == -38277272 && s == "System.Byte[]")
                {
                    return(Plist.writeBinaryByteArray((byte[])obj));
                }
            }
            else if (s == "System.String")
            {
                return(Plist.writeBinaryString((string)obj, true));
            }
            return(new byte[0]);
        }
Example #10
0
        // Token: 0x06000117 RID: 279 RVA: 0x000078C8 File Offset: 0x00005AC8
        private static byte[] composeBinary(object obj)
        {
            string text = obj.GetType().ToString();

            byte[] result;
            switch (text)
            {
            case "System.Collections.Generic.Dictionary`2[System.String,System.Object]":
            {
                byte[] array = Plist.writeBinaryDictionary((Dictionary <string, object>)obj);
                result = array;
                return(result);
            }

            case "System.Collections.Generic.List`1[System.Object]":
            {
                byte[] array = Plist.composeBinaryArray((List <object>)obj);
                result = array;
                return(result);
            }

            case "System.Byte[]":
            {
                byte[] array = Plist.writeBinaryByteArray((byte[])obj);
                result = array;
                return(result);
            }

            case "System.Double":
            {
                byte[] array = Plist.writeBinaryDouble((double)obj);
                result = array;
                return(result);
            }

            case "System.Int32":
            {
                byte[] array = Plist.writeBinaryInteger((int)obj, true);
                result = array;
                return(result);
            }

            case "System.String":
            {
                byte[] array = Plist.writeBinaryString((string)obj, true);
                result = array;
                return(result);
            }

            case "System.DateTime":
            {
                byte[] array = Plist.writeBinaryDate((DateTime)obj);
                result = array;
                return(result);
            }

            case "System.Boolean":
            {
                byte[] array = Plist.writeBinaryBool((bool)obj);
                result = array;
                return(result);
            }
            }
            result = new byte[0];
            return(result);
        }