Created
September 16, 2015 09:46
-
-
Save poulfoged/17ba390b4176691c7ecc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal class ShortNameSerializationBinder<TBase> : DefaultSerializationBinder where TBase : class | |
{ | |
private static Dictionary<string, Type> types; | |
public ShortNameSerializationBinder() | |
{ | |
types = ReflectiveEnumerator.GetEnumerableOfType<TBase>().ToDictionary(i => i.Name, i => i); | |
} | |
public override void BindToName(Type serializedType, out string assemblyName, out string typeName) | |
{ | |
assemblyName = null; | |
typeName = serializedType.Name; | |
} | |
public override Type BindToType(string assemblyName, string typeName) | |
{ | |
return types[typeName]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment