示例#1
0
        public override void WriteBinary(PListBinaryWriter writer)
        {
            int plistElementLength = this.GetPListElementLength();

            byte[] buffer = (byte[])null;
            switch (plistElementLength)
            {
            case 0:
                buffer = new byte[1]
                {
                    (byte)this.Value
                };
                break;

            case 1:
                buffer = BitConverter.GetBytes(IPAddress.HostToNetworkOrder((short)this.Value));
                break;

            case 2:
                buffer = BitConverter.GetBytes(IPAddress.HostToNetworkOrder((int)this.Value));
                break;

            case 3:
                buffer = BitConverter.GetBytes(IPAddress.HostToNetworkOrder(this.Value));
                break;
            }
            writer.BaseStream.Write(buffer, 0, buffer.Length);
        }
示例#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 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);
        }
示例#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)
        {
            Encoding enc = m_IsUTF16 ? Encoding.BigEndianUnicode : Encoding.UTF8;

            Byte[] buf = enc.GetBytes(Value);
            writer.BaseStream.Write(buf, 0, buf.Length);
        }
示例#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 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);
        }
示例#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 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);
        }
示例#6
0
        public void WriteBinary(PListBinaryWriter writer)
        {
            byte[] buffer   = new byte[(int)writer.ElementIdxSize * this.Count];
            long   position = writer.BaseStream.Position;

            writer.BaseStream.Write(buffer, 0, buffer.Length);
            for (int index = 0; index < this.Count; ++index)
            {
                int idx = writer.WriteInternal(this[index]);
                writer.FormatIdx(idx).CopyTo((Array)buffer, (int)writer.ElementIdxSize * index);
            }
            writer.BaseStream.Seek(position, SeekOrigin.Begin);
            writer.BaseStream.Write(buffer, 0, buffer.Length);
            writer.BaseStream.Seek(0L, SeekOrigin.End);
        }
示例#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 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);
        }
示例#8
0
        public void WriteBinary(PListBinaryWriter writer)
        {
            byte[] buffer1  = new byte[(int)writer.ElementIdxSize * this.Count];
            byte[] buffer2  = new byte[(int)writer.ElementIdxSize * this.Count];
            long   position = writer.BaseStream.Position;

            writer.BaseStream.Write(buffer1, 0, buffer1.Length);
            writer.BaseStream.Write(buffer2, 0, buffer2.Length);
            KeyValuePair <string, IPListElement>[] array = this.ToArray <KeyValuePair <string, IPListElement> >();
            for (int index = 0; index < this.Count; ++index)
            {
                int idx = writer.WriteInternal(PListElementFactory.Instance.CreateKeyElement(array[index].Key));
                writer.FormatIdx(idx).CopyTo((Array)buffer1, (int)writer.ElementIdxSize * index);
            }
            for (int index = 0; index < this.Count; ++index)
            {
                int idx = writer.WriteInternal(array[index].Value);
                writer.FormatIdx(idx).CopyTo((Array)buffer2, (int)writer.ElementIdxSize * index);
            }
            writer.BaseStream.Seek(position, SeekOrigin.Begin);
            writer.BaseStream.Write(buffer1, 0, buffer1.Length);
            writer.BaseStream.Write(buffer2, 0, buffer2.Length);
            writer.BaseStream.Seek(0L, SeekOrigin.End);
        }
示例#9
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);
            }
        }
示例#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 void WriteBinary(PListBinaryWriter writer)
 {
 }
示例#11
0
 public override void WriteBinary(PListBinaryWriter writer)
 {
 }
示例#12
0
 public override void WriteBinary(PListBinaryWriter writer)
 {
     byte[] array = ((IEnumerable <byte>)BitConverter.GetBytes((this.Value - new DateTime(2001, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds)).Reverse <byte>().ToArray <byte>();
     writer.BaseStream.Write(array, 0, array.Length);
 }
示例#13
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);
 }
示例#14
0
 public override void WriteBinary(PListBinaryWriter writer)
 {
     byte[] bytes = (this.m_IsUTF16 ? Encoding.BigEndianUnicode : Encoding.UTF8).GetBytes(this.Value);
     writer.BaseStream.Write(bytes, 0, bytes.Length);
 }
示例#15
0
 public override void WriteBinary(PListBinaryWriter writer)
 {
     byte[] array = ((IEnumerable <byte>)BitConverter.GetBytes(this.Value)).Reverse <byte>().ToArray <byte>();
     writer.BaseStream.Write(array, 0, array.Length);
 }
示例#16
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);
 }