Example #1
0
        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);
        }
Example #2
0
        public static XmlObjectContractBuilder Create(XmlObjectContract contract)
        {
            if (contract == null)
            {
                throw new ArgumentNullException(nameof(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(nameof(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
            });
        }
Example #4
0
 public static XmlItemBuilder SetKnownType <T>(this XmlItemBuilder builder, Action <XmlKnownTypeBuilder> build)
 {
     return(SetKnownType(builder, typeof(T), build));
 }
Example #5
0
 public static XmlItemBuilder SetKnownType <T>(this XmlItemBuilder builder, XmlName name = null)
 {
     return(SetKnownType(builder, typeof(T), name));
 }