Exemple #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);
        }
        /// <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;
        }