Example #1
0
        /// <summary>
        /// Loads the PList from specified stream.
        /// </summary>
        /// <param name="stream">The stream containing the PList.</param>
        /// <returns>A <see cref="PListRoot"/> object loaded from the stream</returns>
        public static PListRoot Load(Stream stream)
        {
            PListRoot     root = null;
            XmlSerializer ser  = new XmlSerializer(typeof(PListRoot));

            Byte[] buf = new Byte[8];
            stream.Read(buf, 0, buf.Length);
            stream.Seek(0, SeekOrigin.Begin);
            if (Encoding.Default.GetString(buf) == "bplist00")
            {
                PListBinaryReader reader = new PListBinaryReader();
                root        = new PListRoot();
                root.Format = PListFormat.Binary;
                root.Root   = reader.Read(stream);
            }
            else
            {
                root        = (PListRoot)ser.Deserialize(stream);
                root.Format = PListFormat.Xml;
            }

            return(root);
        }
Example #2
0
        public static PListRoot Load(Stream stream)
        {
            XmlSerializer xmlSerializer = new XmlSerializer(typeof(PListRoot));

            byte[] numArray = new byte[8];
            stream.Read(numArray, 0, numArray.Length);
            stream.Seek(0L, SeekOrigin.Begin);
            PListRoot plistRoot;

            if (Encoding.Default.GetString(numArray) == "bplist00")
            {
                PListBinaryReader plistBinaryReader = new PListBinaryReader();
                plistRoot        = new PListRoot();
                plistRoot.Format = PListFormat.Binary;
                plistRoot.Root   = plistBinaryReader.Read(stream);
            }
            else
            {
                plistRoot        = (PListRoot)xmlSerializer.Deserialize(stream);
                plistRoot.Format = PListFormat.Xml;
            }
            return(plistRoot);
        }