Serialize() публичный Метод

Serialize fields to a stream.
public Serialize ( Stream stream ) : int
stream Stream The stream where serialized instance will be wrote.
Результат int
Пример #1
0
        /// <summary>
        /// Serialize current instance to a stream.
        /// </summary>
        /// <param name="stream">The stream.</param>
        /// <returns>The number of bytes written to the stream.</returns>
        public override int Serialize(Stream stream)
        {
            int size = 0;

            StreamHelper.WriteUInt32(stream, this.propertyTagCount);
            size += 4;
            AdapterHelper.Site.Assert.AreEqual((int)this.propertyTagCount, this.propertyTags.Length, "This field MUST contain PropertyTagCount tags. The expected count is {0}, the actual count is {1}.", this.propertyTagCount, this.propertyTags.Length);

            for (int i = 0; i < this.propertyTagCount; i++)
            {
                PropertyTag tag = this.propertyTags[i].Item1;
                StreamHelper.WriteUInt16(stream, tag.PropertyType);
                StreamHelper.WriteUInt16(stream, tag.PropertyId);
                size += 4;
                if (this.IsNamedProperty(tag))
                {
                    GroupPropertyName name = this.propertyTags[i].Item2;
                    AdapterHelper.Site.Assert.IsNotNull(name, "The property name should not be null.");
                    size += name.Serialize(stream);
                }
            }

            return(size);
        }