countObject() private static method

private static countObject ( object value ) : int
value object
return int
        private static int countObject(object value)
        {
            int    num1 = 0;
            string str  = value.GetType().ToString();
            int    num2;

            if (!(str == "System.Collections.Generic.Dictionary`2[System.String,System.Object]"))
            {
                if (str == "System.Collections.Generic.List`1[System.Object]")
                {
                    foreach (object obj in (List <object>)value)
                    {
                        num1 += Plist.countObject(obj);
                    }
                    num2 = num1 + 1;
                }
                else
                {
                    num2 = num1 + 1;
                }
            }
            else
            {
                Dictionary <string, object> dictionary = (Dictionary <string, object>)value;
                foreach (string key in dictionary.Keys)
                {
                    num1 += Plist.countObject(dictionary[key]);
                }
                num2 = num1 + dictionary.Keys.Count + 1;
            }
            return(num2);
        }
Esempio n. 2
0
        // Token: 0x06000114 RID: 276 RVA: 0x000074D0 File Offset: 0x000056D0
        private static int countObject(object value)
        {
            int    num  = 0;
            string text = value.GetType().ToString();

            if (text != null)
            {
                if (text == "System.Collections.Generic.Dictionary`2[System.String,System.Object]")
                {
                    Dictionary <string, object> dictionary = (Dictionary <string, object>)value;
                    foreach (string current in dictionary.Keys)
                    {
                        num += Plist.countObject(dictionary[current]);
                    }
                    num += dictionary.Keys.Count;
                    num++;
                    return(num);
                }
                if (text == "System.Collections.Generic.List`1[System.Object]")
                {
                    List <object> list = (List <object>)value;
                    foreach (object current2 in list)
                    {
                        num += Plist.countObject(current2);
                    }
                    num++;
                    return(num);
                }
            }
            num++;
            return(num);
        }
        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());
        }
Esempio n. 4
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());
        }