ISerializationBinder Interface

Provides custom binding of a serialized object to a type.

Namespace

System.Runtime.Serialization

Assembly

mscorlib (in mscorlib.dll)

Definition

public interface ISerializationBinder

Members

MemberSignaturePurpose
BindToType Type BindToType(string assemblyName, string typeName) Maps an assembly name and type name to a Type during deserialization.
BindToName void BindToName(Type serializedType, out string assemblyName, out string typeName) Maps a Type to an assembly name and type name during serialization.

Example

using System; using System.Runtime.Serialization; public class SimpleBinder : ISerializationBinder { public Type BindToType(string assemblyName, string typeName) { // Resolve the type from the current assembly return Type.GetType($"{typeName}, {assemblyName}"); } public void BindToName(Type serializedType, out string assemblyName, out string typeName) { // Use the default naming convention assemblyName = serializedType.Assembly.FullName; typeName = serializedType.FullName; } }

See Also