Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Falls back to loading type via standard .NET Type resolution if not f…

…ound in the Assembly's executing directories DLLs.
  • Loading branch information...
commit bac2d0814c1c18cba86df985c9491936702c6349 1 parent dd128bf
john authored
Showing with 21 additions and 5 deletions.
  1. +21 −5 Mite.Builder/MigratorFactory.cs
View
26 Mite.Builder/MigratorFactory.cs
@@ -23,17 +23,33 @@ public static class MigratorFactory {
throw new Exception("Invalid Config - connectionString is required.");
}
object[] args = new object[]{connString, directoryPath};
+
+ IDatabaseRepository databaseRepository = null;
+
foreach (var repoType in databaseRepositories)
{
if (repoName.ToLower() == repoType.Name.ToLower())
{
- var dynamicRepo = (IDatabaseRepository)Activator.CreateInstance(repoType, BindingFlags.CreateInstance, null, args, null);
-
- var miteDb = dynamicRepo.Create();
- return new Migrator(miteDb, dynamicRepo);
+ databaseRepository = (IDatabaseRepository)Activator.CreateInstance(repoType, BindingFlags.CreateInstance, null, args, null);
+ break;
}
}
- throw new Exception("No database repositories match the name: " + repoName);
+
+ if (databaseRepository == null)
+ {
+ try
+ {
+ Type repoType = Type.GetType(repoName);
+ databaseRepository = (IDatabaseRepository)Activator.CreateInstance(repoType, BindingFlags.CreateInstance, null, args, null);
+ }
+ catch (TypeLoadException ex)
+ {
+ throw new Exception("Could not load repository: " + repoName);
+ }
+ }
+
+ var miteDb = databaseRepository.Create();
+ return new Migrator(miteDb, databaseRepository);
}
public static Migrator GetMigrator(string directoryName) {
Please sign in to comment.
Something went wrong with that request. Please try again.