public static void InitializeWithDefaults(this IDocumentStore documentStore, bool isDataToBeSeeded, IList <Type> indexesToExecute) { Condition.Requires(documentStore).IsNotNull(); // Default initializtion; documentStore.Initialize(); // Index initialisation. if (indexesToExecute != null) { Type[] indexes = (from type in indexesToExecute where type.IsSubclassOf(typeof(AbstractIndexCreationTask)) select type).ToArray(); IndexCreation.CreateIndexes(new CompositionContainer(new TypeCatalog(indexes)), documentStore); } else { IndexCreation.CreateIndexes(typeof(RecentPopularTags).Assembly, documentStore); } // Create our Seed Data (if required). // NOTE: This would be handled differently if it was a -real- production system. // Like, wrapping this called in a #if RELEASE #endif, for example. if (isDataToBeSeeded) { HelperUtilities.CreateSeedData(documentStore); } // Now lets check to make sure there are now errors. documentStore.AssertDocumentStoreErrors(); }
/// <summary> /// Initialized this instance but with some optional settings, like seed data and indexes. /// </summary> /// <param name="documentStore">The Raven document store.</param> /// <param name="seedData">Optional: A collection of data which will be 'seeded' into the new document store.</param> /// <param name="indexesToExecute">Optional: Any index(es) which should be executed during initialization. They need to be assignable from an AbstractIndexCreationTask.</param> /// <param name="assembliesToScanForIndexes">Optional: The assembly where the index(es) are located.</param> /// <param name="areDocumentStoreErrorsTreatedAsWarnings">Optional: If there are any server errors, do we downgrade them as warnings or keep them as errors, which stops further processing of the document store.</param> public static async Task InitializeWithDefaultsAsync(this IDocumentStore documentStore, IEnumerable<IEnumerable> seedData = null, ICollection<Type> indexesToExecute = null, ICollection<Type> assembliesToScanForIndexes = null, bool areDocumentStoreErrorsTreatedAsWarnings = false) { // Default initialization; documentStore.Initialize(); // Static indexes or ResultTransformers. CreateIndexes(indexesToExecute, assembliesToScanForIndexes, documentStore); // Create our Seed Data (if provided). if (seedData != null) { await CreateSeedDataAsync(seedData, documentStore); } // Now lets check to make sure there are now errors. documentStore.AssertDocumentStoreErrors(areDocumentStoreErrorsTreatedAsWarnings); // Display any statistics. ReportOnInitializedStatistics(documentStore); }
public static void InitializeWithDefaults(this IDocumentStore documentStore) { documentStore.Initialize(); IndexCreation.CreateIndexes(typeof(ContactEmailsByConfirmationCode).Assembly, documentStore); documentStore.AssertDocumentStoreErrors(); }