Esempio n. 1
0
        /// <summary>
        /// Writes this element binary to the writer.
        /// </summary>
        /// <param name="writer">The <see cref="T:CE.iPhone.PListBinaryWriter"/> to which the element is written.</param>
        /// <remarks>Provided for internal use only.</remarks>
        public void WriteBinary(PListBinaryWriter writer)
        {
            Byte[] keys      = new Byte[writer.ElementIdxSize * Count];
            Byte[] values    = new Byte[writer.ElementIdxSize * Count];
            long   streamPos = writer.BaseStream.Position;

            writer.BaseStream.Write(keys, 0, keys.Length);
            writer.BaseStream.Write(values, 0, values.Length);

            KeyValuePair <String, IPListElement>[] elems = this.ToArray();

            for (int i = 0; i < Count; i++)
            {
                int elementIdx = writer.WriteInternal(PListElementFactory.Instance.CreateKeyElement(elems[i].Key));
                writer.FormatIdx(elementIdx).CopyTo(keys, writer.ElementIdxSize * i);
            }
            for (int i = 0; i < Count; i++)
            {
                int elementIdx = writer.WriteInternal(elems[i].Value);
                writer.FormatIdx(elementIdx).CopyTo(values, writer.ElementIdxSize * i);
            }

            writer.BaseStream.Seek(streamPos, SeekOrigin.Begin);
            writer.BaseStream.Write(keys, 0, keys.Length);
            writer.BaseStream.Write(values, 0, values.Length);
            writer.BaseStream.Seek(0, SeekOrigin.End);
        }
Esempio n. 2
0
        /// <summary>
        /// Writes this element binary to the writer.
        /// </summary>
        /// <param name="writer">The <see cref="T:CE.iPhone.PListBinaryWriter"/> to which the element is written.</param>
        /// <remarks>Provided for internal use only.</remarks>
        public override void WriteBinary(PListBinaryWriter writer)
        {
            Encoding enc = m_IsUTF16 ? Encoding.BigEndianUnicode : Encoding.UTF8;

            Byte[] buf = enc.GetBytes(Value);
            writer.BaseStream.Write(buf, 0, buf.Length);
        }
Esempio n. 3
0
        /// <summary>
        /// Writes this element binary to the writer.
        /// </summary>
        /// <param name="writer">The <see cref="T:CE.iPhone.PListBinaryWriter"/> to which the element is written.</param>
        /// <remarks>Provided for internal use only.</remarks>
        public override void WriteBinary(PListBinaryWriter writer)
        {
            Debug.WriteLine("Unverified", "WARNING");

            DateTime start = new DateTime(2001, 1, 1, 0, 0, 0, DateTimeKind.Utc);

            TimeSpan ts = Value - start;

            Byte[] buf = BitConverter.GetBytes(ts.TotalSeconds).Reverse().ToArray();
            writer.BaseStream.Write(buf, 0, buf.Length);
        }
Esempio n. 4
0
        /// <summary>
        /// Writes this element binary to the writer.
        /// </summary>
        /// <param name="writer">The <see cref="T:CE.iPhone.PListBinaryWriter"/> to which the element is written.</param>
        /// <remarks>Provided for internal use only.</remarks>
        public void WriteBinary(PListBinaryWriter writer)
        {
            Byte[] elements  = new Byte[writer.ElementIdxSize * Count];
            long   streamPos = writer.BaseStream.Position;

            writer.BaseStream.Write(elements, 0, elements.Length);
            for (int i = 0; i < Count; i++)
            {
                int elementIdx = writer.WriteInternal(this[i]);
                writer.FormatIdx(elementIdx).CopyTo(elements, writer.ElementIdxSize * i);
            }
            writer.BaseStream.Seek(streamPos, SeekOrigin.Begin);
            writer.BaseStream.Write(elements, 0, elements.Length);
            writer.BaseStream.Seek(0, SeekOrigin.End);
        }
Esempio n. 5
0
        /// <summary>
        /// Writes this element binary to the writer.
        /// </summary>
        /// <param name="writer">The <see cref="T:CE.iPhone.PListBinaryWriter"/> to which the element is written.</param>
        /// <remarks>Provided for internal use only.</remarks>
        public override void WriteBinary(PListBinaryWriter writer)
        {
            int length = GetPListElementLength();

            Byte[] buf = null;
            switch (length)
            {
            case 0: buf = new Byte[] { (Byte)Value }; break;

            case 1: buf = BitConverter.GetBytes(IPAddress.HostToNetworkOrder((Int16)Value)); break;

            case 2: buf = BitConverter.GetBytes(IPAddress.HostToNetworkOrder((Int32)Value)); break;

            case 3: buf = BitConverter.GetBytes(IPAddress.HostToNetworkOrder((Int64)Value)); break;
            }
            writer.BaseStream.Write(buf, 0, buf.Length);
        }
Esempio n. 6
0
        /// <summary>
        /// Saves the PList to the specified stream.
        /// </summary>
        /// <param name="stream">The stream in which the PList is saves.</param>
        /// <param name="format">The format of the PList (Binary/Xml).</param>
        public void Save(Stream stream, PListFormat format)
        {
            if (format == PListFormat.Xml)
            {
                XmlWriterSettings sets = new XmlWriterSettings();
                sets.Encoding     = Encoding.UTF8;
                sets.Indent       = true;
                sets.IndentChars  = "\t";
                sets.NewLineChars = "\n";

                XmlWriter xmlWriter = XmlTextWriter.Create(stream, sets);

                xmlWriter.WriteStartDocument();
                xmlWriter.WriteDocType("plist", "-//Apple Computer//DTD PLIST 1.0//EN", "http://www.apple.com/DTDs/PropertyList-1.0.dtd", null);

                WriteXml(xmlWriter);
                xmlWriter.Flush();
            }
            else
            {
                PListBinaryWriter writer = new PListBinaryWriter();
                writer.Write(stream, Root);
            }
        }
Esempio n. 7
0
 /// <summary>
 /// Writes this element binary to the writer.
 /// </summary>
 /// <param name="writer">The <see cref="T:CE.iPhone.PListBinaryWriter"/> to which the element is written.</param>
 /// <remarks>Provided for internal use only.</remarks>
 public void WriteBinary(PListBinaryWriter writer)
 {
 }
Esempio n. 8
0
 /// <summary>
 /// Writes this element binary to the writer.
 /// </summary>
 /// <param name="writer">The <see cref="T:CE.iPhone.PListBinaryWriter"/> to which the element is written.</param>
 /// <remarks>Provided for internal use only.</remarks>
 public override void WriteBinary(PListBinaryWriter writer)
 {
     Byte[] buf = BitConverter.GetBytes(Value).Reverse().ToArray();
     writer.BaseStream.Write(buf, 0, buf.Length);
 }
Esempio n. 9
0
 /// <summary>
 /// Writes this element binary to the writer.
 /// </summary>
 /// <param name="writer">The <see cref="T:CE.iPhone.PListBinaryWriter"/> to which the element is written.</param>
 /// <remarks>Provided for internal use only.</remarks>
 public override void WriteBinary(PListBinaryWriter writer)
 {
 }
Esempio n. 10
0
 /// <summary>
 /// Writes this element binary to the writer.
 /// </summary>
 /// <param name="writer">The <see cref="T:CE.iPhone.PListBinaryWriter"/> to which the element is written.</param>
 /// <remarks>Provided for internal use only.</remarks>
 public abstract void WriteBinary(PListBinaryWriter writer);
Esempio n. 11
0
 /// <summary>
 /// Writes this element binary to the writer.
 /// </summary>
 /// <param name="writer">The <see cref="T:CE.iPhone.PListBinaryWriter"/> to which the element is written.</param>
 /// <remarks>Provided for internal use only.</remarks>
 public override void WriteBinary(PListBinaryWriter writer)
 {
     writer.BaseStream.Write(Value, 0, Value.Length);
 }