Exemple #1
0
        public void Serialize(IntermediateWriter output, ContentSerializerAttribute format, object collection)
        {
            if (output == null)
            {
                throw new ArgumentNullException("output");
            }
            if (format == null)
            {
                throw new ArgumentNullException("format");
            }
            this.ValidateCollectionType(collection);
            IEnumerable enumerable = (IEnumerable)collection;

            if (this.contentSerializer is IXmlListItemSerializer)
            {
                ContentSerializerAttribute contentSerializerAttribute = new ContentSerializerAttribute();
                contentSerializerAttribute.FlattenContent = true;
                bool        flag       = true;
                IEnumerator enumerator = enumerable.GetEnumerator();
                try
                {
                    while (enumerator.MoveNext())
                    {
                        object current = enumerator.Current;
                        if (flag)
                        {
                            flag = false;
                        }
                        else
                        {
                            output.Xml.WriteWhitespace(" ");
                        }
                        output.WriteRawObject <object>(current, contentSerializerAttribute, this.contentSerializer);
                    }
                    return;
                }
                finally
                {
                    IDisposable disposable = enumerator as IDisposable;
                    if (disposable != null)
                    {
                        disposable.Dispose();
                    }
                }
            }
            ContentSerializerAttribute contentSerializerAttribute2 = new ContentSerializerAttribute();

            contentSerializerAttribute2.ElementName = format.CollectionItemName;
            foreach (object current2 in enumerable)
            {
                output.WriteObject <object>(current2, contentSerializerAttribute2, this.contentSerializer);
            }
        }
 protected internal override void Serialize(IntermediateWriter output, T?value, ContentSerializerAttribute format)
 {
     output.WriteRawObject <T>(value.Value, this.underlyingFormat, this.underlyingTypeSerializer);
 }