Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: issues with binding to library #2272

Merged
merged 1 commit into from
Dec 5, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions src/ReactiveUI/Mixins/DependencyResolverMixins.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public static void InitializeReactiveUI(this IMutableDependencyResolver resolver
var assemblyName = new AssemblyName(fdr.AssemblyQualifiedName.Replace(fdr.FullName + ", ", string.Empty));

extraNs
.Where(GetNamespaceExists)
.ForEach(ns => ProcessRegistrationForNamespace(ns, assemblyName, resolver));
}

Expand Down Expand Up @@ -109,10 +108,10 @@ private static Func<object> TypeFactory(TypeInfo typeInfo)
}

[SuppressMessage("Globalization", "CA1307: operator could change based on locale settings", Justification = "Replace() does not have third parameter on all platforms")]
private static void ProcessRegistrationForNamespace(string ns, AssemblyName assemblyName, IMutableDependencyResolver resolver)
private static void ProcessRegistrationForNamespace(string namespaceName, AssemblyName assemblyName, IMutableDependencyResolver resolver)
{
var targetType = ns + ".Registrations";
var fullName = targetType + ", " + assemblyName.FullName.Replace(assemblyName.Name, ns);
var targetType = namespaceName + ".Registrations";
var fullName = targetType + ", " + assemblyName.FullName.Replace(assemblyName.Name, namespaceName);

var registerTypeClass = Reflection.ReallyFindType(fullName, false);
if (registerTypeClass != null)
Expand All @@ -121,12 +120,5 @@ private static void ProcessRegistrationForNamespace(string ns, AssemblyName asse
registerer.Register((f, t) => resolver.RegisterConstant(f(), t));
}
}

private static bool GetNamespaceExists(string namespaceName)
{
string folderPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string assemblyPath = Path.Combine(folderPath, new AssemblyName(namespaceName).Name + ".dll");
return File.Exists(assemblyPath);
}
}
}