Class ObjectSerializerFactory
Inheritance
Implements
Inherited Members
Namespace: EPiServer.Framework.Serialization
Assembly: EPiServer.Framework.dll
Version: 8.11.0Syntax
[ServiceConfiguration(typeof(IObjectSerializerFactory), Lifecycle = ServiceInstanceScope.Singleton)]
public class ObjectSerializerFactory : IObjectSerializerFactory
Constructors
ObjectSerializerFactory(ServiceCollectionAccessor<IObjectSerializer>)
Initializes a new instance of the ObjectSerializerFactory class.
Declaration
public ObjectSerializerFactory(ServiceCollectionAccessor<IObjectSerializer> serializers)
Parameters
Type | Name | Description |
---|---|---|
ServiceCollectionAccessor<IObjectSerializer> | serializers |
ObjectSerializerFactory(IEnumerable<ServiceAccessor<IObjectSerializer>>)
Initializes a new instance of the ObjectSerializerFactory class.
Declaration
[Obsolete("Constructor does not support multiple serializers with normal registration")]
public ObjectSerializerFactory(IEnumerable<ServiceAccessor<IObjectSerializer>> serializers)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<ServiceAccessor<IObjectSerializer>> | serializers | The initial serializers. |
Methods
GetSerializer(String)
Gets the serializer for the given content type.
Declaration
public virtual IObjectSerializer GetSerializer(string contentType)
Parameters
Type | Name | Description |
---|---|---|
System.String | contentType | The content type. |
Returns
Type | Description |
---|---|
IObjectSerializer | An IObjectSerializer for the given content type or null if no serializer is registered for the content type. |
RegisterSerializer(IObjectSerializer)
Registers an IObjectSerializer for a given content type.
Declaration
public void RegisterSerializer(IObjectSerializer serializer)
Parameters
Type | Name | Description |
---|---|---|
IObjectSerializer | serializer | The serializer. |
Remarks
This overrides any existing serializer.
RegisterSerializer(ServiceAccessor<IObjectSerializer>)
Registers an IObjectSerializer for all content types that the serializer specifies in HandledContentTypes.
Declaration
public void RegisterSerializer(ServiceAccessor<IObjectSerializer> accessor)
Parameters
Type | Name | Description |
---|---|---|
ServiceAccessor<IObjectSerializer> | accessor | The accessor. |
Remarks
This replaces any existing serializer.
RegisterSerializer(String, IObjectSerializer)
Registers an IObjectSerializer for a given content type.
Declaration
public void RegisterSerializer(string contentType, IObjectSerializer serializer)
Parameters
Type | Name | Description |
---|---|---|
System.String | contentType | The content type to handle. |
IObjectSerializer | serializer | The serializer. |
Remarks
This overrides any existing serializer.
RegisterSerializer(String, ServiceAccessor<IObjectSerializer>)
Registers an IObjectSerializer for a given content type.
Declaration
public void RegisterSerializer(string contentType, ServiceAccessor<IObjectSerializer> accessor)
Parameters
Type | Name | Description |
---|---|---|
System.String | contentType | The content type to handle. |
ServiceAccessor<IObjectSerializer> | accessor | The creator function. |