public static TBuilder SetItem <TBuilder>(this TBuilder builder, Type valueType, Action <XmlItemBuilder> build)
            where TBuilder : IXmlCollectionBuilder
        {
            var item = new XmlItemBuilder(valueType);

            build(item);
            builder.Item = item;
            return(builder);
        }
        public static XmlObjectContractBuilder Create(XmlObjectContract contract)
        {
            if (contract == null)
            {
                throw new ArgumentNullException("contract");
            }

            return(new XmlObjectContractBuilder(contract.ValueType)
            {
                Name = contract.Name,
                TypeHandling = contract.TypeHandling,
                Properties = XmlPropertyBuilderCollection.Create(contract.Properties),
                Item = contract.Item != null?XmlItemBuilder.Create(contract.Item) : null
            });
        }
        public static XmlPropertyBuilder Create(XmlProperty property)
        {
            if (property == null)
            {
                throw new ArgumentNullException("property");
            }

            return(new XmlPropertyBuilder(property.PropertyInfo)
            {
                Name = property.Name,
                MappingType = property.MappingType,
                NullValueHandling = property.NullValueHandling,
                TypeHandling = property.TypeHandling,
                DefaultValueHandling = property.DefaultValueHandling,
                DefaultValue = property.DefaultValue,
                IsRequired = property.IsRequired,
                IsCollection = property.IsCollection,
                Order = property.Order,
                Item = property.Item != null?XmlItemBuilder.Create(property.Item) : null,
                           KnownTypes = property.KnownTypes != null?XmlKnownTypeBuilderCollection.Create(property.KnownTypes) : null
            });
        }
 public static XmlItemBuilder SetKnownType <T>(this XmlItemBuilder builder, Action <XmlKnownTypeBuilder> build)
 {
     return(SetKnownType(builder, typeof(T), build));
 }
 public static XmlItemBuilder SetKnownType <T>(this XmlItemBuilder builder, XmlName name = null)
 {
     return(SetKnownType(builder, typeof(T), name));
 }