コード例 #1
0
 /// <summary>
 /// Reads this element binary from the reader.
 /// </summary>
 /// <param name="reader">The <see cref="T:CE.iPhone.PListBinaryReader"/> from which the element is read.</param>
 /// <remarks>Provided for internal use only.</remarks>
 public abstract void ReadBinary(PListBinaryReader reader);
コード例 #2
0
 /// <summary>
 /// Reads this element binary from the reader.
 /// </summary>
 /// <param name="reader">The <see cref="T:CE.iPhone.PListBinaryReader"/> from which the element is read.</param>
 /// <remarks>Provided for internal use only.</remarks>
 public void ReadBinary(PListBinaryReader reader)
 {
     if (reader.CurrentElementLength != 0x00)
         throw new PListFormatException();
 }
コード例 #3
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;
        }