private static Type GetTypeFromTypeNameKey(DefaultSerializationBinder.TypeNameKey typeNameKey) { string assemblyName = typeNameKey.AssemblyName; string typeName = typeNameKey.TypeName; if (assemblyName == null) { return(Type.GetType(typeName)); } Assembly assembly = Assembly.Load(assemblyName); if (assembly == null) { throw new JsonSerializationException("Could not load assembly '{0}'.".FormatWith(CultureInfo.InvariantCulture, new object[] { assemblyName })); } Type type = assembly.GetType(typeName); if (type == null) { throw new JsonSerializationException("Could not find type '{0}' in assembly '{1}'.".FormatWith(CultureInfo.InvariantCulture, new object[] { typeName, assembly.FullName })); } return(type); }
private static Type GetTypeFromTypeNameKey( DefaultSerializationBinder.TypeNameKey typeNameKey) { string assemblyName = typeNameKey.AssemblyName; string typeName = typeNameKey.TypeName; if (assemblyName == null) { return(Type.GetType(typeName)); } Assembly assembly1 = Assembly.Load(assemblyName); if (assembly1 == null) { foreach (Assembly assembly2 in AppDomain.CurrentDomain.GetAssemblies()) { if (assembly2.FullName == assemblyName) { assembly1 = assembly2; break; } } } if (assembly1 == null) { throw new JsonSerializationException("Could not load assembly '{0}'.".FormatWith((IFormatProvider)CultureInfo.InvariantCulture, (object)assemblyName)); } Type type = assembly1.GetType(typeName); if (type != null) { return(type); } throw new JsonSerializationException("Could not find type '{0}' in assembly '{1}'.".FormatWith((IFormatProvider)CultureInfo.InvariantCulture, (object)typeName, (object)assembly1.FullName)); }
private static Type GetTypeFromTypeNameKey(DefaultSerializationBinder.TypeNameKey typeNameKey) { string partialName = typeNameKey.AssemblyName; string str = typeNameKey.TypeName; if (partialName == null) { return(Type.GetType(str)); } Assembly assembly = Assembly.LoadWithPartialName(partialName); if (assembly == null) { throw new JsonSerializationException(StringUtils.FormatWith("Could not load assembly '{0}'.", (IFormatProvider)CultureInfo.InvariantCulture, (object)partialName)); } Type type = assembly.GetType(str); if (type == null) { throw new JsonSerializationException(StringUtils.FormatWith("Could not find type '{0}' in assembly '{1}'.", (IFormatProvider)CultureInfo.InvariantCulture, (object)str, (object)assembly.FullName)); } else { return(type); } }
public bool Equals(DefaultSerializationBinder.TypeNameKey other) { if (this.AssemblyName != other.AssemblyName) { return(false); } return(this.TypeName == other.TypeName); }
private static Type GetTypeFromTypeNameKey(DefaultSerializationBinder.TypeNameKey typeNameKey) { string assemblyName = typeNameKey.AssemblyName; string typeName = typeNameKey.TypeName; if (assemblyName == null) { return(Type.GetType(typeName)); } Assembly assembly = Assembly.Load(assemblyName); if (assembly == null) { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); int num = 0; while (num < (int)assemblies.Length) { Assembly assembly1 = assemblies[num]; if (assembly1.FullName != assemblyName) { num++; } else { assembly = assembly1; break; } } } if (assembly == null) { throw new JsonSerializationException("Could not load assembly '{0}'.".FormatWith(CultureInfo.InvariantCulture, assemblyName)); } Type type = assembly.GetType(typeName); if (type == null) { throw new JsonSerializationException("Could not find type '{0}' in assembly '{1}'.".FormatWith(CultureInfo.InvariantCulture, typeName, assembly.FullName)); } return(type); }
private static Type GetTypeFromTypeNameKey(DefaultSerializationBinder.TypeNameKey typeNameKey) { string assemblyName = typeNameKey.AssemblyName; string typeName = typeNameKey.TypeName; if (assemblyName == null) { return(Type.GetType(typeName)); } Assembly assembly = Assembly.LoadWithPartialName(assemblyName); if (assembly == null) { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); Assembly[] array = assemblies; for (int i = 0; i < array.Length; i++) { Assembly assembly2 = array[i]; if (assembly2.FullName == assemblyName) { assembly = assembly2; break; } } } if (assembly == null) { throw new JsonSerializationException("Could not load assembly '{0}'.".FormatWith(CultureInfo.InvariantCulture, assemblyName)); } Type type = assembly.GetType(typeName); if (type == null) { throw new JsonSerializationException("Could not find type '{0}' in assembly '{1}'.".FormatWith(CultureInfo.InvariantCulture, typeName, assembly.FullName)); } return(type); }