private XmlSerializer CreateOverrideSerializer() { SoapAttributeOverrides mySoapAttributeOverrides = new SoapAttributeOverrides(); SoapAttributes mySoapAttributes = new SoapAttributes(); // Create a new SoapAttributeAttribute to override the // one applied to the Group class. The resulting XML // stream will use the new namespace and attribute name. SoapAttributeAttribute mySoapAttribute = new SoapAttributeAttribute(); mySoapAttribute.AttributeName = "TeamName"; // Change the Namespace. mySoapAttribute.Namespace = "http://www.cohowinery.com"; mySoapAttributes.SoapAttribute = mySoapAttribute; mySoapAttributeOverrides. Add(typeof(Group), "GroupName", mySoapAttributes); XmlTypeMapping myMapping = (new SoapReflectionImporter (mySoapAttributeOverrides)).ImportTypeMapping(typeof(Group)); XmlSerializer ser = new XmlSerializer(myMapping); return(ser); }
public void DataTypeDefault() { SoapAttributeAttribute attr = new SoapAttributeAttribute(); Assert.AreEqual(string.Empty, attr.DataType, "#1"); attr.DataType = null; Assert.AreEqual(string.Empty, attr.DataType, "#2"); }
public void AttributeNameDefault() { SoapAttributeAttribute attr = new SoapAttributeAttribute(); Assert.AreEqual(string.Empty, attr.AttributeName, "#1"); attr.AttributeName = null; Assert.AreEqual(string.Empty, attr.AttributeName, "#2"); }
/// <include file='doc\SoapAttributes.uex' path='docs/doc[@for="SoapAttributes.SoapAttributes1"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public SoapAttributes(ICustomAttributeProvider provider) { object[] attrs = provider.GetCustomAttributes(false); for (int i = 0; i < attrs.Length; i++) { if (attrs[i] is SoapIgnoreAttribute || attrs[i] is ObsoleteAttribute) { _soapIgnore = true; break; } else if (attrs[i] is SoapElementAttribute) { _soapElement = (SoapElementAttribute)attrs[i]; } else if (attrs[i] is SoapAttributeAttribute) { _soapAttribute = (SoapAttributeAttribute)attrs[i]; } else if (attrs[i] is SoapTypeAttribute) { _soapType = (SoapTypeAttribute)attrs[i]; } else if (attrs[i] is SoapEnumAttribute) { _soapEnum = (SoapEnumAttribute)attrs[i]; } else if (attrs[i] is DefaultValueAttribute) { _soapDefaultValue = ((DefaultValueAttribute)attrs[i]).Value; } } if (_soapIgnore) { _soapElement = null; _soapAttribute = null; _soapType = null; _soapEnum = null; _soapDefaultValue = null; } }
public void NamespaceDefault() { SoapAttributeAttribute attr = new SoapAttributeAttribute(); Assert.IsNull(attr.Namespace); }