public static IRepository ChangeRepository(DataStoreType dataStoreType, string connectionString, bool enableCache) { if (dataStoreType.RequiresCustomRepository) { IRepository customRepository = LoadRepositoryFromType(dataStoreType.CustomRepositoryType); ObjectFactory.Configure(x => { x.For<IRepository>().HybridHttpOrThreadLocalScoped().Use(customRepository); }); } else { ObjectFactory.Configure(x => { x.For<IRepository>().HybridHttpOrThreadLocalScoped().Use<LightSpeedRepository>(); }); } IRepository repository = ObjectFactory.GetInstance<IRepository>(); repository.Startup(dataStoreType, connectionString, enableCache); return repository; }
public static DataStoreType ByName(string name) { // Default to SQL Server, but warn DataStoreType dataStoreType = SqlServer2005; #if MONO dataStoreType = MongoDB; // default to MongoDB for Mono #endif if (!string.IsNullOrEmpty(name)) { dataStoreType = DataStoreType.AllTypes.FirstOrDefault(x => x.Name.ToLower() == name.ToLower()); if (dataStoreType == null) { throw new DatabaseException("Unable to find a data store provider for " + name, null); } } else { Log.Warn("No name provided for DataStoreType.ByName - defaulting to SQLServer2005"); } return(dataStoreType); }
/// <summary> /// Resets DataStoreType.AllTypes to have just one type, "mock datastore" /// </summary> /// <param name="existingModel"></param> private void SetMockDataStoreType(SettingsViewModel existingModel) { string typeName = typeof(RepositoryMock).AssemblyQualifiedName; DataStoreType mockDataStoreType = new DataStoreType("mock datastore", "mock", typeName); List<DataStoreType> datastoreTypes = new List<DataStoreType>() { mockDataStoreType }; DataStoreType.AllTypes = datastoreTypes; existingModel.DataStoreTypeName = "mock datastore"; }
public virtual void TestConnection(DataStoreType dataStoreType, string connectionString) { }
public virtual void Install(DataStoreType dataStoreType, string connectionString, bool enableCache) { Installed = true; InstalledDataStoreType = dataStoreType; InstalledConnectionString = connectionString; InstalledEnableCache = enableCache; }
public void Startup(DataStoreType dataStoreType, string connectionString, bool enableCache) { }
// ...2 other database tests: // No MySQL/Postgres upgrades as they didn't work in 1.5.2 private void UpdateWebConfig(string connectionstring, DataStoreType databaseType) { string sitePath = Settings.WEB_PATH; string webConfigPath = Path.Combine(sitePath, "web.config"); // Remove the readonly flag File.SetAttributes(webConfigPath, FileAttributes.Normal); // Switch to previous version + update connection string in the web.config ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap(); fileMap.ExeConfigFilename = webConfigPath; System.Configuration.Configuration config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None); RoadkillSection section = config.GetSection("roadkill") as RoadkillSection; section.Version = "1.5.2"; section.Installed = true; section.DataStoreType = databaseType.Name; config.ConnectionStrings.ConnectionStrings["Roadkill"].ConnectionString = connectionstring; config.Save(ConfigurationSaveMode.Minimal); Console.WriteLine("Updated {0} for upgrade tests", webConfigPath); }
public override void TestConnection(DataStoreType dataStoreType, string connectionString) { throw new Exception(ExceptionMessage); }
public override void Install(DataStoreType dataStoreType, string connectionString, bool enableCache) { throw new Exception(ExceptionMessage); }