/// <summary> /// Creates an instance of a class that inherits from <see cref="T:System.Runtime.Serialization.XmlObjectSerializer"/> for serialization and deserialization operations with an <see cref="T:System.Xml.XmlDictionaryString"/> that contains the namespace. /// </summary> /// <param name="type">The type to serialize or deserialize.</param> /// <param name="name">The name of the serialized type.</param> /// <param name="ns">An <see cref="T:System.Xml.XmlDictionaryString"/> that contains the namespace of the serialized type.</param> /// <param name="knownTypes">An <see cref="T:System.Collections.Generic.IList`1"/> of <see cref="T:System.Type"/> that contains known types.</param> /// <returns> /// An instance of a class that inherits from the <see cref="T:System.Runtime.Serialization.XmlObjectSerializer"/> class. /// </returns> public override XmlObjectSerializer CreateSerializer( Type type, XmlDictionaryString name, XmlDictionaryString ns, IList<Type> knownTypes) { var serializer = new PrefixDataContractSerializer( type, name, ns, knownTypes, MaxItemsInObjectGraph, IgnoreExtensionDataObject, false, DataContractSurrogate); AddPrefixes(serializer); return serializer; }
private void AddPrefixes(PrefixDataContractSerializer serializer) { foreach (RegisterNamespacePrefixAttribute attr in prefixAttributes) { serializer.RegisterNamespace(attr.Prefix, attr.XmlNamespace); } }