public static TBuilder RemoveProperty <TBuilder>(this TBuilder builder, string propertyName)
            where TBuilder : XmlObjectContractBuilder
        {
            if (builder.Properties != null)
            {
                var propertyInfo = XmlPropertyBuilder.GetPropertyInfo(builder.ValueType, propertyName);
                builder.Properties.Remove(propertyInfo);
            }

            return(builder);
        }
        public static XmlObjectContractBuilder <T> RemoveProperty <T, TProperty>(
            this XmlObjectContractBuilder <T> builder,
            Expression <Func <T, TProperty> > expression)
        {
            if (builder.Properties != null)
            {
                var propertyInfo = XmlPropertyBuilder.GetPropertyInfo(expression);
                builder.Properties.Remove(propertyInfo);
            }

            return(builder);
        }
        public static XmlObjectContractBuilder <T> SetProperty <T, TProperty>(
            this XmlObjectContractBuilder <T> builder,
            Expression <Func <T, TProperty> > expression,
            Action <XmlPropertyBuilder> build)
        {
            if (build == null)
            {
                throw new ArgumentNullException("build");
            }

            var property = XmlPropertyBuilder.Create <T, TProperty>(expression);

            build(property);

            if (builder.Properties == null)
            {
                builder.Properties = new XmlPropertyBuilderCollection();
            }

            builder.Properties.Set(property);

            return(builder);
        }
        public static TBuilder SetProperty <TBuilder>(
            this TBuilder builder,
            string propertyName,
            Action <XmlPropertyBuilder> build)
            where TBuilder : XmlObjectContractBuilder
        {
            if (build == null)
            {
                throw new ArgumentNullException("build");
            }

            var property = XmlPropertyBuilder.Create(builder.ValueType, propertyName);

            build(property);

            if (builder.Properties == null)
            {
                builder.Properties = new XmlPropertyBuilderCollection();
            }

            builder.Properties.Set(property);

            return(builder);
        }
Exemplo n.º 5
0
 public static XmlPropertyBuilder SetKnownType <T>(this XmlPropertyBuilder builder, Action <XmlKnownTypeBuilder> build)
 {
     return(SetKnownType(builder, typeof(T), build));
 }
Exemplo n.º 6
0
 public static XmlPropertyBuilder SetKnownType <T>(this XmlPropertyBuilder builder, XmlName name = null)
 {
     return(SetKnownType(builder, typeof(T), name));
 }
Exemplo n.º 7
0
 public static XmlPropertyBuilder SetCollection(this XmlPropertyBuilder builder, bool isCollection = true)
 {
     builder.IsCollection = isCollection;
     return(builder);
 }
Exemplo n.º 8
0
 public static XmlPropertyBuilder SetRequired(this XmlPropertyBuilder builder, bool isRequired = true)
 {
     builder.IsRequired = isRequired;
     return(builder);
 }
Exemplo n.º 9
0
 public static XmlPropertyBuilder SetOrder(this XmlPropertyBuilder builder, int order)
 {
     builder.Order = order;
     return(builder);
 }
Exemplo n.º 10
0
 public static XmlPropertyBuilder SetMappingType(this XmlPropertyBuilder builder, XmlMappingType mappingType)
 {
     builder.MappingType = mappingType;
     return(builder);
 }