Example #1
0
        // Token: 0x060001ED RID: 493 RVA: 0x00007BFC File Offset: 0x00005DFC
        private static byte[] composeBinary(object obj)
        {
            string left = obj.GetType().ToString();

            byte[] result;
            if (Operators.CompareString(left, "System.Collections.Generic.Dictionary`2[System.String,System.Object]", false) == 0)
            {
                byte[] array = Plist.writeBinaryDictionary((Dictionary <string, object>)obj);
                result = array;
            }
            else if (Operators.CompareString(left, "System.Collections.Generic.List`1[System.Object]", false) == 0)
            {
                byte[] array = Plist.composeBinaryArray((List <object>)obj);
                result = array;
            }
            else if (Operators.CompareString(left, "System.Byte[]", false) == 0)
            {
                byte[] array = Plist.writeBinaryByteArray((byte[])obj);
                result = array;
            }
            else if (Operators.CompareString(left, "System.Double", false) == 0)
            {
                byte[] array = Plist.writeBinaryDouble((double)obj);
                result = array;
            }
            else if (Operators.CompareString(left, "System.Int32", false) == 0)
            {
                byte[] array = Plist.writeBinaryInteger((int)obj, true);
                result = array;
            }
            else if (Operators.CompareString(left, "System.String", false) == 0)
            {
                byte[] array = Plist.writeBinaryString((string)obj, true);
                result = array;
            }
            else if (Operators.CompareString(left, "System.DateTime", false) == 0)
            {
                byte[] array = Plist.writeBinaryDate((DateTime)obj);
                result = array;
            }
            else if (Operators.CompareString(left, "System.Boolean", false) == 0)
            {
                byte[] array = Plist.writeBinaryBool((bool)obj);
                result = array;
            }
            else
            {
                result = new byte[0];
            }
            return(result);
        }
Example #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());
            }
        }