Пример #1
0
        // Token: 0x060001EA RID: 490 RVA: 0x0000779C File Offset: 0x0000599C
        private static int countObject(object value)
        {
            int    num  = 0;
            string left = value.GetType().ToString();

            checked
            {
                if (Operators.CompareString(left, "System.Collections.Generic.Dictionary`2[System.String,System.Object]", false) == 0)
                {
                    Dictionary <string, object> dictionary = (Dictionary <string, object>)value;
                    try
                    {
                        foreach (string key in dictionary.Keys)
                        {
                            num += Plist.countObject(RuntimeHelpers.GetObjectValue(dictionary[key]));
                        }
                    }
                    finally
                    {
                        Dictionary <string, object> .KeyCollection.Enumerator enumerator;
                        ((IDisposable)enumerator).Dispose();
                    }
                    num += dictionary.Keys.Count;
                    Math.Max(Interlocked.Increment(ref num), num - 1);
                }
                else if (Operators.CompareString(left, "System.Collections.Generic.List`1[System.Object]", false) == 0)
                {
                    List <object> list = (List <object>)value;
                    try
                    {
                        foreach (object obj in list)
                        {
                            object objectValue = RuntimeHelpers.GetObjectValue(obj);
                            num += Plist.countObject(RuntimeHelpers.GetObjectValue(objectValue));
                        }
                    }
                    finally
                    {
                        List <object> .Enumerator enumerator2;
                        ((IDisposable)enumerator2).Dispose();
                    }
                    Math.Max(Interlocked.Increment(ref num), num - 1);
                }
                else
                {
                    Math.Max(Interlocked.Increment(ref num), num - 1);
                }
                return(num);
            }
        }
Пример #2
0
        // Token: 0x060001E1 RID: 481 RVA: 0x00006F74 File Offset: 0x00005174
        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 = checked (Plist.countObject(RuntimeHelpers.GetObjectValue(value)) - 1);

            Plist.refCount   = num;
            Plist.objRefSize = Plist.RegulateNullBytes(BitConverter.GetBytes(Plist.refCount)).Length;
            Plist.composeBinary(RuntimeHelpers.GetObjectValue(value));
            Plist.writeBinaryString("bplist00", false);
            Plist.offsetTableOffset = (long)Plist.objectTable.Count;
            checked
            {
                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();
                int i = 0;
                while (i < Plist.offsetTable.Count)
                {
                    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);
                    Math.Max(Interlocked.Increment(ref i), i - 1);
                }
                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(unchecked ((long)num) + 1L);
                Array.Reverse(bytes);
                Plist.objectTable.AddRange(bytes);
                Plist.objectTable.AddRange(BitConverter.GetBytes(0));
                bytes = BitConverter.GetBytes(Plist.offsetTableOffset);
                Array.Reverse(bytes);
                Plist.objectTable.AddRange(bytes);
                return(Plist.objectTable.ToArray());
            }
        }