-Added ISerializationBinder
-Added SerializationBinder properties to JsonSerializer and JsonSerializerSettings -Changed Binder properties on JsonSerializer and JsonSerializerSettings to obsolete
This commit is contained in:
@@ -151,23 +151,9 @@ namespace Newtonsoft.Json.Utilities
|
||||
return (v != null) ? v.GetType() : null;
|
||||
}
|
||||
|
||||
public static string GetTypeName(Type t, FormatterAssemblyStyle assemblyFormat, SerializationBinder binder)
|
||||
public static string GetTypeName(Type t, FormatterAssemblyStyle assemblyFormat, ISerializationBinder binder)
|
||||
{
|
||||
string fullyQualifiedTypeName;
|
||||
#if !(NET20 || NET35)
|
||||
if (binder != null)
|
||||
{
|
||||
string assemblyName, typeName;
|
||||
binder.BindToName(t, out assemblyName, out typeName);
|
||||
fullyQualifiedTypeName = typeName + (assemblyName == null ? "" : ", " + assemblyName);
|
||||
}
|
||||
else
|
||||
{
|
||||
fullyQualifiedTypeName = t.AssemblyQualifiedName;
|
||||
}
|
||||
#else
|
||||
fullyQualifiedTypeName = t.AssemblyQualifiedName;
|
||||
#endif
|
||||
string fullyQualifiedTypeName = GetFullyQualifiedTypeName(t, binder);
|
||||
|
||||
switch (assemblyFormat)
|
||||
{
|
||||
@@ -180,6 +166,25 @@ namespace Newtonsoft.Json.Utilities
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetFullyQualifiedTypeName(Type t, ISerializationBinder binder)
|
||||
{
|
||||
if (binder != null)
|
||||
{
|
||||
string assemblyName, typeName;
|
||||
binder.BindToName(t, out assemblyName, out typeName);
|
||||
#if (NET20 || NET35)
|
||||
// for older SerializationBinder implementations that didn't have BindToName
|
||||
if (assemblyName == null & typeName == null)
|
||||
{
|
||||
return t.AssemblyQualifiedName;
|
||||
}
|
||||
#endif
|
||||
return typeName + (assemblyName == null ? "" : ", " + assemblyName);
|
||||
}
|
||||
|
||||
return t.AssemblyQualifiedName;
|
||||
}
|
||||
|
||||
private static string RemoveAssemblyDetails(string fullyQualifiedTypeName)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
Reference in New Issue
Block a user