XmlDataContractSerializerOutputFormatter Class¶
Summary¶
This class handles serialization of objects to XML using [System.Runtime.Serialization.DataContractSerializer]()
Syntax¶
public class XmlDataContractSerializerOutputFormatter : OutputFormatter, IOutputFormatter, IApiResponseFormatMetadataProvider
Constructors¶
-
Microsoft.AspNet.Mvc.Xml.XmlDataContractSerializerOutputFormatter.XmlDataContractSerializerOutputFormatter()
Initializes a new instance of [Microsoft.AspNet.Mvc.Xml.XmlDataContractSerializerOutputFormatter](Microsoft.AspNet.Mvc.Xml.XmlDataContractSerializerOutputFormatter.yml) with default XmlWriterSettings
public XmlDataContractSerializerOutputFormatter()
-
XmlDataContractSerializerOutputFormatter
(System.Xml.XmlWriterSettings)¶ Initializes a new instance of [Microsoft.AspNet.Mvc.Xml.XmlDataContractSerializerOutputFormatter](Microsoft.AspNet.Mvc.Xml.XmlDataContractSerializerOutputFormatter.yml)
Arguments: - writerSettings (System.Xml.XmlWriterSettings) – The settings to be used by the [System.Runtime.Serialization.DataContractSerializer]().
public XmlDataContractSerializerOutputFormatter(XmlWriterSettings writerSettings)
-
Properties¶
-
SerializerSettings
()¶ Gets or sets the [System.Runtime.Serialization.DataContractSerializerSettings]() used to configure the [System.Runtime.Serialization.DataContractSerializer]().
Return type: System.Runtime.Serialization.DataContractSerializerSettings public DataContractSerializerSettings SerializerSettings { get; set; }
-
WrapperProviderFactories
()¶ Gets the list of [Microsoft.AspNet.Mvc.Xml.IWrapperProviderFactory](Microsoft.AspNet.Mvc.Xml.IWrapperProviderFactory.yml) to provide the wrapping type for serialization.
Return type: System.Collections.Generic.IList{Microsoft.AspNet.Mvc.Xml.IWrapperProviderFactory} public IList<IWrapperProviderFactory> WrapperProviderFactories { get; }
-
WriterSettings
()¶ Gets the settings to be used by the XmlWriter.
Return type: System.Xml.XmlWriterSettings public XmlWriterSettings WriterSettings { get; }
-
Methods¶
-
CanWriteType
(System.Type, System.Type)¶ Arguments: - declaredType (System.Type) –
- runtimeType (System.Type) –
Return type: System.Boolean
protected override bool CanWriteType(Type declaredType, Type runtimeType)
-
CreateSerializer
(System.Type)¶ Create a new instance of [System.Runtime.Serialization.DataContractSerializer]() for the given object type.
Arguments: - type (System.Type) – The type of object for which the serializer should be created.
Return type: System.Runtime.Serialization.DataContractSerializer
Returns: A new instance of [System.Runtime.Serialization.DataContractSerializer]()
protected virtual DataContractSerializer CreateSerializer(Type type)
-
CreateXmlWriter
(System.IO.Stream, System.Xml.XmlWriterSettings)¶ Creates a new instance of [System.Xml.XmlWriter]() using the given stream and the [Microsoft.AspNet.Mvc.Xml.XmlDataContractSerializerOutputFormatter.WriterSettings](Microsoft.AspNet.Mvc.Xml.XmlDataContractSerializerOutputFormatter.yml).
Arguments: - writeStream (System.IO.Stream) – The stream on which the XmlWriter should operate on.
- xmlWriterSettings (System.Xml.XmlWriterSettings) –
Return type: System.Xml.XmlWriter
Returns: A new instance of [System.Xml.XmlWriter]()
public virtual XmlWriter CreateXmlWriter(Stream writeStream, XmlWriterSettings xmlWriterSettings)
-
GetCachedSerializer
(System.Type)¶ Gets the cached serializer or creates and caches the serializer for the given type.
Arguments: - type (System.Type) –
Return type: System.Runtime.Serialization.DataContractSerializer
Returns: The [System.Runtime.Serialization.DataContractSerializer]() instance.
protected virtual DataContractSerializer GetCachedSerializer(Type type)
-
GetSerializableType
(System.Type)¶ Gets the type to be serialized.
Arguments: - type (System.Type) – The original type to be serialized
Return type: System.Type
Returns: The original or wrapped type provided by any [Microsoft.AspNet.Mvc.Xml.IWrapperProvider](Microsoft.AspNet.Mvc.Xml.IWrapperProvider.yml)s.
protected virtual Type GetSerializableType(Type type)
-
ResolveType
(System.Type, System.Type)¶ Gets the type of the object to be serialized.
Arguments: - declaredType (System.Type) – The declared type.
- runtimeType (System.Type) – The runtime type.
Return type: System.Type
Returns: The type of the object to be serialized.
protected virtual Type ResolveType(Type declaredType, Type runtimeType)
-
WriteResponseBodyAsync
(Microsoft.AspNet.Mvc.OutputFormatterContext)¶ Arguments: - context (Microsoft.AspNet.Mvc.OutputFormatterContext) –
Return type: System.Threading.Tasks.Task
public override Task WriteResponseBodyAsync(OutputFormatterContext context)
-