Пример #1
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);
        }
Пример #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());
        }
Пример #3
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 object parseBinaryByteArray(int headerPosition)
        {
            int newBytePosition;
            int count = Plist.getCount(headerPosition, out newBytePosition);

            return((object)Plist.objectTable.GetRange(newBytePosition, count).ToArray());
        }
Пример #5
0
        // Token: 0x06000122 RID: 290 RVA: 0x00007EC0 File Offset: 0x000060C0
        private static object parseBinaryDictionary(int objRef)
        {
            Dictionary <string, object> dictionary = new Dictionary <string, object>();
            List <int> list = new List <int>();
            int        num;
            int        count = Plist.getCount(Plist.offsetTable[objRef], out num);

            if (count < 15)
            {
                num = Plist.offsetTable[objRef] + 1;
            }
            else
            {
                num = Plist.offsetTable[objRef] + 2 + Plist.RegulateNullBytes(BitConverter.GetBytes(count), 1).Length;
            }
            for (int i = num; i < num + count * 2 * Plist.objRefSize; i += Plist.objRefSize)
            {
                byte[] array = Plist.objectTable.GetRange(i, Plist.objRefSize).ToArray();
                Array.Reverse(array);
                list.Add(BitConverter.ToInt32(Plist.RegulateNullBytes(array, 4), 0));
            }
            for (int i = 0; i < count; i++)
            {
                dictionary.Add((string)Plist.parseBinary(list[i]), Plist.parseBinary(list[i + count]));
            }
            return(dictionary);
        }
Пример #6
0
        // Token: 0x06000108 RID: 264 RVA: 0x00006B20 File Offset: 0x00004D20
        public static string writeXml(object value)
        {
            string @string;

            using (MemoryStream memoryStream = new MemoryStream())
            {
                using (XmlWriter xmlWriter = XmlWriter.Create(memoryStream, new XmlWriterSettings
                {
                    Encoding = new UTF8Encoding(false),
                    ConformanceLevel = ConformanceLevel.Document,
                    Indent = true
                }))
                {
                    xmlWriter.WriteStartDocument();
                    xmlWriter.WriteDocType("plist", "-//Apple Computer//DTD PLIST 1.0//EN", "http://www.apple.com/DTDs/PropertyList-1.0.dtd", null);
                    xmlWriter.WriteStartElement("plist");
                    xmlWriter.WriteAttributeString("version", "1.0");
                    Plist.compose(value, xmlWriter);
                    xmlWriter.WriteEndElement();
                    xmlWriter.WriteEndDocument();
                    xmlWriter.Flush();
                    xmlWriter.Close();
                    @string = Encoding.UTF8.GetString(memoryStream.ToArray());
                }
            }
            return(@string);
        }
Пример #7
0
 // Token: 0x06000106 RID: 262 RVA: 0x00006AA0 File Offset: 0x00004CA0
 public static void writeXml(object value, string path)
 {
     using (StreamWriter streamWriter = new StreamWriter(path))
     {
         streamWriter.Write(Plist.writeXml(value));
     }
 }
        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);
        }
Пример #9
0
 // Token: 0x0600010A RID: 266 RVA: 0x00006C44 File Offset: 0x00004E44
 public static void writeBinary(object value, Stream stream)
 {
     using (BinaryWriter binaryWriter = new BinaryWriter(stream))
     {
         binaryWriter.Write(Plist.writeBinary(value));
     }
 }
Пример #10
0
 // Token: 0x06000107 RID: 263 RVA: 0x00006AE0 File Offset: 0x00004CE0
 public static void writeXml(object value, Stream stream)
 {
     using (StreamWriter streamWriter = new StreamWriter(stream))
     {
         streamWriter.Write(Plist.writeXml(value));
     }
 }
Пример #11
0
        // Token: 0x06000105 RID: 261 RVA: 0x00006A0C File Offset: 0x00004C0C
        public static object readPlist(Stream stream, plistType type)
        {
            if (type == plistType.Auto)
            {
                type = Plist.getPlistType(stream);
                stream.Seek(0L, SeekOrigin.Begin);
            }
            object result;

            if (type == plistType.Binary)
            {
                using (BinaryReader binaryReader = new BinaryReader(stream))
                {
                    byte[] data = binaryReader.ReadBytes((int)binaryReader.BaseStream.Length);
                    result = Plist.readBinary(data);
                    return(result);
                }
            }
            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.XmlResolver = null;
            xmlDocument.Load(stream);
            result = Plist.readXml(xmlDocument);
            return(result);
        }
Пример #12
0
 // Token: 0x06000109 RID: 265 RVA: 0x00006BFC File Offset: 0x00004DFC
 public static void writeBinary(object value, string path)
 {
     using (BinaryWriter binaryWriter = new BinaryWriter(new FileStream(path, FileMode.Create)))
     {
         binaryWriter.Write(Plist.writeBinary(value));
     }
 }
        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());
        }
        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());
        }
        private static object parseBinaryUnicodeString(int headerPosition)
        {
            int newBytePosition;
            int length = Plist.getCount(headerPosition, out newBytePosition) * 2;

            byte[] bytes = new byte[length];
            int    index = 0;

            while (index < length)
            {
                byte num1 = Plist.objectTable.GetRange(newBytePosition + index, 1)[0];
                byte num2 = Plist.objectTable.GetRange(newBytePosition + index + 1, 1)[0];
                if (BitConverter.IsLittleEndian)
                {
                    bytes[index]     = num2;
                    bytes[index + 1] = num1;
                }
                else
                {
                    bytes[index]     = num1;
                    bytes[index + 1] = num2;
                }
                index += 2;
            }
            return((object)Encoding.Unicode.GetString(bytes));
        }
Пример #16
0
        // Token: 0x0600012C RID: 300 RVA: 0x00008428 File Offset: 0x00006628
        private static object parseBinaryByteArray(int headerPosition)
        {
            int index;
            int count = Plist.getCount(headerPosition, out index);

            return(Plist.objectTable.GetRange(index, count).ToArray());
        }
        private static Dictionary <string, object> parseDictionary(XmlNode node)
        {
            XmlNodeList childNodes = node.ChildNodes;

            if (childNodes.Count % 2 != 0)
            {
                throw new DataMisalignedException("Dictionary elements must have an even number of child nodes");
            }
            Dictionary <string, object> dictionary = new Dictionary <string, object>();
            int index = 0;

            while (index < childNodes.Count)
            {
                XmlNode xmlNode = childNodes[index];
                XmlNode node1   = childNodes[index + 1];
                if (xmlNode.Name != "key")
                {
                    throw new ApplicationException("expected a key node");
                }
                object obj = Plist.parse(node1);
                if (obj != null)
                {
                    dictionary.Add(xmlNode.InnerText, obj);
                }
                index += 2;
            }
            return(dictionary);
        }
Пример #18
0
        // Token: 0x0600012A RID: 298 RVA: 0x00008348 File Offset: 0x00006548
        private static object parseBinaryAsciiString(int headerPosition)
        {
            int         index;
            int         count = Plist.getCount(headerPosition, out index);
            List <byte> range = Plist.objectTable.GetRange(index, count);

            return((range.Count > 0) ? Encoding.ASCII.GetString(range.ToArray()) : string.Empty);
        }
        public static byte[] writeBinaryDate(DateTime obj)
        {
            List <byte> byteList = new List <byte>((IEnumerable <byte>)Plist.RegulateNullBytes(BitConverter.GetBytes(PlistDateConverter.ConvertToAppleTimeStamp(obj)), 8));

            byteList.Reverse();
            byteList.Insert(0, (byte)51);
            Plist.objectTable.InsertRange(0, (IEnumerable <byte>)byteList);
            return(byteList.ToArray());
        }
Пример #20
0
 // Token: 0x06000121 RID: 289 RVA: 0x00007E6C File Offset: 0x0000606C
 private static void parseOffsetTable(List <byte> offsetTableBytes)
 {
     for (int i = 0; i < offsetTableBytes.Count; i += Plist.offsetByteSize)
     {
         byte[] array = offsetTableBytes.GetRange(i, Plist.offsetByteSize).ToArray();
         Array.Reverse(array);
         Plist.offsetTable.Add(BitConverter.ToInt32(Plist.RegulateNullBytes(array, 4), 0));
     }
 }
 private static void composeArray(List <object> value, XmlWriter writer)
 {
     writer.WriteStartElement("array");
     foreach (object obj in value)
     {
         Plist.compose(obj, writer);
     }
     writer.WriteEndElement();
 }
Пример #22
0
        // Token: 0x06000129 RID: 297 RVA: 0x000082EC File Offset: 0x000064EC
        private static object parseBinaryReal(int headerPosition)
        {
            byte b     = Plist.objectTable[headerPosition];
            int  count = (int)Math.Pow(2.0, (double)(b & 15));

            byte[] array = Plist.objectTable.GetRange(headerPosition + 1, count).ToArray();
            Array.Reverse(array);
            return(BitConverter.ToDouble(Plist.RegulateNullBytes(array, 8), 0));
        }
Пример #23
0
        // Token: 0x06000128 RID: 296 RVA: 0x00008288 File Offset: 0x00006488
        private static object parseBinaryInt(int headerPosition, out int newHeaderPosition)
        {
            byte b   = Plist.objectTable[headerPosition];
            int  num = (int)Math.Pow(2.0, (double)(b & 15));

            byte[] array = Plist.objectTable.GetRange(headerPosition + 1, num).ToArray();
            Array.Reverse(array);
            newHeaderPosition = headerPosition + num + 1;
            return(BitConverter.ToInt32(Plist.RegulateNullBytes(array, 4), 0));
        }
        private static object parseBinaryReal(int headerPosition)
        {
            int count = (int)Math.Pow(2.0, (double)((int)Plist.objectTable[headerPosition] & 15));

            byte[] array = Plist.objectTable.GetRange(headerPosition + 1, count).ToArray();
            Array.Reverse((Array)array);
            int minBytes = 8;

            return((object)BitConverter.ToDouble(Plist.RegulateNullBytes(array, minBytes), 0));
        }
Пример #25
0
        // Token: 0x06000101 RID: 257 RVA: 0x00006954 File Offset: 0x00004B54
        public static object readPlist(string path)
        {
            object result;

            using (FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read))
            {
                result = Plist.readPlist(fileStream, plistType.Auto);
            }
            return(result);
        }
Пример #26
0
 // Token: 0x06000120 RID: 288 RVA: 0x00007DE0 File Offset: 0x00005FE0
 private static void parseTrailer(List <byte> trailer)
 {
     Plist.offsetByteSize = BitConverter.ToInt32(Plist.RegulateNullBytes(trailer.GetRange(6, 1).ToArray(), 4), 0);
     Plist.objRefSize     = BitConverter.ToInt32(Plist.RegulateNullBytes(trailer.GetRange(7, 1).ToArray(), 4), 0);
     byte[] array = trailer.GetRange(12, 4).ToArray();
     Array.Reverse(array);
     Plist.refCount = BitConverter.ToInt32(array, 0);
     byte[] array2 = trailer.GetRange(24, 8).ToArray();
     Array.Reverse(array2);
     Plist.offsetTableOffset = BitConverter.ToInt64(array2, 0);
 }
Пример #27
0
 // Token: 0x06000113 RID: 275 RVA: 0x00007454 File Offset: 0x00005654
 private static void writeDictionaryValues(Dictionary <string, object> dictionary, XmlWriter writer)
 {
     writer.WriteStartElement("dict");
     foreach (string current in dictionary.Keys)
     {
         object value = dictionary[current];
         writer.WriteElementString("key", current);
         Plist.compose(value, writer);
     }
     writer.WriteEndElement();
 }
        private static object parseBinaryAsciiString(int headerPosition)
        {
            int         newBytePosition;
            int         count = Plist.getCount(headerPosition, out newBytePosition);
            List <byte> range = Plist.objectTable.GetRange(newBytePosition, count);

            if (range.Count <= 0)
            {
                return((object)string.Empty);
            }
            return((object)Encoding.ASCII.GetString(range.ToArray()));
        }
        private static void parseOffsetTable(List <byte> offsetTableBytes)
        {
            int index = 0;

            while (index < offsetTableBytes.Count)
            {
                byte[] array = offsetTableBytes.GetRange(index, Plist.offsetByteSize).ToArray();
                Array.Reverse((Array)array);
                Plist.offsetTable.Add(BitConverter.ToInt32(Plist.RegulateNullBytes(array, 4), 0));
                index += Plist.offsetByteSize;
            }
        }
 private static void writeDictionaryValues(Dictionary <string, object> dictionary, XmlWriter writer)
 {
     writer.WriteStartElement("dict");
     foreach (string key in dictionary.Keys)
     {
         object obj = dictionary[key];
         writer.WriteElementString("key", key);
         XmlWriter writer1 = writer;
         Plist.compose(obj, writer1);
     }
     writer.WriteEndElement();
 }