public DocumentDatabase(RavenConfiguration configuration) { this.configuration = configuration; workContext = new WorkContext(); TransactionalStorage = new TransactionalStorage(configuration.DataDirectory, workContext.NotifyAboutWork); bool newDb; try { newDb = TransactionalStorage.Initialize(); } catch (Exception) { TransactionalStorage.Dispose(); throw; } IndexDefinitionStorage = new IndexDefinitionStorage(configuration.DataDirectory); IndexStorage = new IndexStorage(configuration.DataDirectory, IndexDefinitionStorage); workContext.IndexStorage = IndexStorage; workContext.TransactionaStorage = TransactionalStorage; workContext.IndexDefinitionStorage = IndexDefinitionStorage; if (!newDb) return; if(configuration.ShouldCreateDefaultsWhenBuildingNewDatabaseFromScratch) { PutIndex("Raven/DocumentsByEntityName", new IndexDefinition { Map = @" from doc in docs where doc[""@metadata""][""Raven-Entity-Name""] != null select new { Tag = doc[""@metadata""][""Raven-Entity-Name""] }; " }); } configuration.RaiseDatabaseCreatedFromScratch(this); }
public DocumentDatabase(RavenConfiguration configuration) { Configuration = configuration; configuration.Container.SatisfyImportsOnce(this); workContext = new WorkContext {IndexUpdateTriggers = IndexUpdateTriggers}; TransactionalStorage = new TransactionalStorage(configuration, workContext.NotifyAboutWork); configuration.Container.SatisfyImportsOnce(TransactionalStorage); bool newDb; try { newDb = TransactionalStorage.Initialize(); } catch (Exception) { TransactionalStorage.Dispose(); throw; } IndexDefinitionStorage = new IndexDefinitionStorage( TransactionalStorage, configuration.DataDirectory, configuration.Container.GetExportedValues<AbstractViewGenerator>()); IndexStorage = new IndexStorage(IndexDefinitionStorage, configuration); workContext.IndexStorage = IndexStorage; workContext.TransactionaStorage = TransactionalStorage; workContext.IndexDefinitionStorage = IndexDefinitionStorage; InitializeTriggers(); ExecuteStartupTasks(); if (!newDb) return; OnNewlyCreatedDatabase(); }