Share via


AllowedTypesSerializationBinder Class

Definition

An implementation of the Newtonsoft.Json.Serialization.DefaultSerializationBinder, capable of allowing only desired Types to be serialized and deserialized.

public class AllowedTypesSerializationBinder : Newtonsoft.Json.Serialization.DefaultSerializationBinder
type AllowedTypesSerializationBinder = class
    inherit DefaultSerializationBinder
Public Class AllowedTypesSerializationBinder
Inherits DefaultSerializationBinder
Inheritance
Newtonsoft.Json.Serialization.DefaultSerializationBinder
AllowedTypesSerializationBinder

Constructors

AllowedTypesSerializationBinder(IList<Type>)

Initializes a new instance of the AllowedTypesSerializationBinder class.

Properties

AllowedTypes

Gets the collection of the allowed types.

Methods

BindToName(Type, String, String)

Given the serializedType parameter, it evaluates if the Type is allowed by this SerializationBinder.

Either allowed or not allowed, it will output the name of the Type through the typeName parameter.

When allowed, it will add the Type to the AllowedTypes collection.

BindToType(String, String)

Given the assemblyName and typeName parameters, it validates if the resulted Type is found in the AllowedTypes collection, and returns its value.

When found, it will add the Type to the AllowedTypes collection if it doesn't exist.

Verify()

Verifies if there are types that are not allowed.

When not allowed, it will throw an InvalidOperationException.

Applies to