Beispiel #1
0
        /// <summary>
        /// Reads partial data for the container from the specified format.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <param name="container">The container.</param>
        public override void Read(IFormatReader reader, object container)
        {
            using (reader.Section(this.Tag))
            {
                int length = reader.ReadInteger("Length");

                ICollection <TElement> collection = this.ReadCollection(reader, length);
                var array = collection as TElement[];

                for (int i = 0; i < length; i++)
                {
                    using (reader.Section(this.ElementTag))
                    {
                        TElement element = this.ReadElement(reader);
                        if (array != null)
                        {
                            array[i] = element;
                        }
                        else
                        {
                            collection.Add(element);
                        }
                    }
                }

                this.SetAction(container, collection);
            }
        }
Beispiel #2
0
 /// <summary>
 /// Reads the property for the specified container.
 /// </summary>
 /// <param name="reader">The reader.</param>
 /// <param name="container">The container.</param>
 public override void Read(IFormatReader reader, object container)
 {
     this.SetAction(container, reader.ReadInteger(this.Tag));
 }
Beispiel #3
0
 /// <summary>
 /// Reads a value out of the specified reader.
 /// </summary>
 /// <param name="reader">The reader.</param>
 /// <returns></returns>
 public override int Read(IFormatReader reader)
 {
     return(reader.ReadInteger("Value"));
 }