/// <summary>
        /// Tries to find configuration Type.
        /// If none or multiple found NULL will be returned.
        /// </summary>
        /// <param name="projectPath"></param>
        /// <param name="repoType"></param>
        /// <param name="multipleFound"></param>
        /// <returns></returns>
        internal static Type FindSingleConfiguration(string projectPath, Type repoType, out bool multipleFound)
        {
            multipleFound = false;

            var loadedProject = new ProjectEvalutionHelper().LoadEvalutionProject(projectPath);

            var baseType    = typeof(RepoMigrationConfigurationBase <>).MakeGenericType(repoType);
            var configTypes = loadedProject
                              .GetTypes()
                              .Where(baseType.IsAssignableFrom)
                              .ToArray();

            //if none found then we will end up creating one.
            if (!configTypes.Any())
            {
                return(null);
            }

            if (configTypes.Length == 1)
            {
                return(configTypes.Single());
            }

            multipleFound = true;
            return(null);
        }
        /// <summary>
        /// Finds all migration Types / Classes from the given project.
        /// </summary>
        /// <param name="projectPath"></param>
        /// <param name="repoType"></param>
        /// <returns></returns>
        internal static Type[] FindAllMigrations(string projectPath, Type repoType)
        {
            var loadedProject = new ProjectEvalutionHelper().LoadEvalutionProject(projectPath);

            var baseType = typeof(BaseMigration <>).MakeGenericType(repoType);

            return(loadedProject
                   .GetTypes()
                   .Where(baseType.IsAssignableFrom)
                   .ToArray());
        }
        /// <summary>
        /// Tries to find the implementation of the base repo object from the given project.
        /// Will return NULL if more than one is found.  The name can be passed in if the repo name is known, (required if multiple repos in same project).
        /// </summary>
        /// <param name="projectPath"></param>
        /// <param name="optionalRepoName"></param>
        /// <returns></returns>
        internal static RepoSearchResult FindSingleRepo(string projectPath, string optionalRepoName)
        {
            LoggerBase.Log(string.Format("Starting to find single Repo: '{0}, {1}", optionalRepoName, projectPath), isDebugMessage: true);

            var loadedProject = new ProjectEvalutionHelper().LoadEvalutionProject(projectPath);

            LoggerBase.Log("LoadedProject: " + loadedProject.FullName, isDebugMessage: true);

            var repoTypes = new Type[0];

            try
            {
                repoTypes = loadedProject
                            .GetTypes()
                            .Where(t =>
                                   t.IsSubclassOf(typeof(BaseRepo)) &&
                                   !t.IsGenericType
                                   )
                            .ToArray();
            }
            catch (ReflectionTypeLoadException ex)
            {
                LoggerBase.Log("Error whilst getting all classes that inherit from baserepo within loadedproject");

                Exception[] loaderExceptions = ex.LoaderExceptions;
                LoggerBase.Log("Logger exceptions:", isDebugMessage: true);
                foreach (var exception in loaderExceptions)
                {
                    LoggerBase.Log(exception, isDebugMessage: true);
                }

                LoggerBase.Log(ex, isDebugMessage: true);
                throw;
            }

            if (!string.IsNullOrWhiteSpace(optionalRepoName))
            {
                var repos = repoTypes.Where(r => r.Name.Equals(optionalRepoName, StringComparison.InvariantCultureIgnoreCase)).ToArray();
                if (!repos.Any())
                {
                    LoggerBase.Log("No repo class found with name: " + optionalRepoName);
                    return(null);
                }

                if (repos.Count() > 1)
                {
                    LoggerBase.Log("More than one repo with same name found, please ensure repo is uniquely named in repo project.");
                    return(null);
                }

                return(new RepoSearchResult(loadedProject, repos.Single()));
            }

            if (!repoTypes.Any())
            {
                LoggerBase.Log("No repo class found");
                return(null);
            }

            if (repoTypes.Count() > 1)
            {
                LoggerBase.Log("More than one repo found, please specify which repo to use.");
                return(null);
            }

            return(new RepoSearchResult(loadedProject, repoTypes.Single()));
        }