internal override void BindConfiguration(ConfigurationBindingContext bindingContext) { var attributes = new XmlAttributes { XmlArray = new XmlArrayAttribute() }; if (false == string.IsNullOrWhiteSpace(this.elementName)) { attributes.XmlArray.ElementName = this.elementName; } if (false == this.Property.PropertyType.IsArray) { bindingContext.Overrides.Add(bindingContext.EntityType, this.Property.Name, attributes); return; } var elementType = this.Property.PropertyType.GetElementType(); Type elementProxyType; if (bindingContext.ProxyTypes.TryGetValue(elementType, out elementProxyType)) { var itemAttribute = new XmlArrayItemAttribute { ElementName = this.childElementName, Type = elementProxyType }; attributes.XmlArrayItems.Add(itemAttribute); } bindingContext.Overrides.Add(bindingContext.EntityType, this.Property.Name, attributes); }
internal override void BindConfiguration(ConfigurationBindingContext bindingContext) { var elementAttribute = new XmlElementAttribute(); if (false == string.IsNullOrWhiteSpace(this.elementName)) { elementAttribute.ElementName = this.elementName; } if (false == string.IsNullOrWhiteSpace(this.elementNamespace)) { elementAttribute.Namespace = this.elementNamespace; } var propertyType = this.Property.PropertyType; if (this.Property.PropertyType.IsArray) { propertyType = this.Property.PropertyType.GetElementType(); } Type proxyType; if (bindingContext.ProxyTypes.TryGetValue(propertyType, out proxyType)) { elementAttribute.Type = proxyType; } var attributes = new XmlAttributes(); attributes.XmlElements.Add(elementAttribute); bindingContext.Overrides.Add(bindingContext.EntityType, this.Property.Name, attributes); }
internal override void BindConfiguration(ConfigurationBindingContext bindingContext) { var attributes = new XmlAttributes { XmlAnyAttribute = new XmlAnyAttributeAttribute() }; bindingContext.Overrides.Add(bindingContext.EntityType, this.Property.Name, attributes); }
internal override void BindConfiguration(ConfigurationBindingContext bindingContext) { var attributes = new XmlAttributes { XmlEnum = new XmlEnumAttribute() }; if (false == string.IsNullOrWhiteSpace(this.valueName)) { attributes.XmlEnum.Name = this.valueName; } bindingContext.Overrides.Add(bindingContext.EntityType, this.Property.Name, attributes); }
/// <summary> /// Binds the entity configuration to the Xml serializer context. /// </summary> /// <param name="context">Xml serializer context to bind the configured entity to.</param> internal void BindEntityToModel(SerializerConfigurationContext context) { var bindingContext = new ConfigurationBindingContext { Overrides = context.Attributes, ProxyTypes = new ReadOnlyDictionary <Type, Type>(context.ProxyTypes), EntityType = this.EntityType }; Type entityProxyType; if (context.ProxyTypes.TryGetValue(this.EntityType, out entityProxyType)) { bindingContext.EntityType = entityProxyType; } foreach (var p in this.PropertyConfigurations) { p.BindConfiguration(bindingContext); } }
internal abstract void BindConfiguration(ConfigurationBindingContext bindingContext);