public UnitFactory() { if (factory == null || factory.Count == 0) { RepositoryConfiguration configuration = RepositoryConfiguration.GetConfig(); RepositoryCollection col = configuration.RepositoryCollection; IEnumerable <Repository> Repo = col.Cast <Repository>(); factory = new Dictionary <string, Type>(); foreach (Repository item in Repo) { Type type = Type.GetType(item.DataBase); factory.Add(item.RepositoryName, type); } } }