public static XmlObjectContractBuilder <T> SetProperty <T, TProperty>(
     this XmlObjectContractBuilder <T> builder,
     Expression <Func <T, TProperty> > expression,
     XmlName name = null,
     XmlMappingType mappingType = XmlMappingType.Element)
 {
     return(SetProperty(builder, expression, x => x.SetName(name).SetMappingType(mappingType)));
 }
        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);
        }