/// <summary> /// No more configuration needed for event store - now configure something else or start event store. /// </summary> /// <param name="cfg"></param> /// <returns></returns> public static BaseConfiguration Done(this EventStoreConfiguration cfg) { IAppendOnlyStore aStore = cfg.Get <IAppendOnlyStore>(AppendOnlyStore_SettingsKey); ISerializer messageSerializer = cfg.Get <ISerializer>(MessageSerializer_SettingsKey); if (aStore == null) { throw new InvalidOperationException("Mising storage mechanism (IAppendOnlyStore) for event store."); } if (messageSerializer == null) { throw new InvalidOperationException("Missing event serializer for event store."); } EventStoreDB eStore = new EventStoreDB(aStore, messageSerializer); cfg.Set(EventStoreDB_SettingsKey, eStore); IObjectContainer container = Xyperico.Agres.Configuration.ObjectContainerConfigurationExtensions.GetObjectContainer(cfg); container.RegisterInstance <IEventStore>(eStore); return(new BaseConfiguration(cfg)); }
/// <summary> /// Use file based storing of events and internal data structures. /// </summary> /// <param name="cfg"></param> /// <param name="baseDir"></param> /// <returns></returns> public static EventStoreConfiguration WithFileDocumentStore(this EventStoreConfiguration cfg, string baseDir) { if (cfg.ContainsKey(DocumentStoreFactory_SettingsKey)) { throw new InvalidOperationException("You should not configure document store for event store twice."); } Logger.Debug("Using plain files for storing documents used in event store"); Condition.Requires(cfg, "cfg").IsNotNull(); Condition.Requires(baseDir, "baseDir").IsNotNull(); IDocumentSerializer documentSerializer = cfg.Get <IDocumentSerializer>(DocumentSerializer_SettingsKey); if (documentSerializer == null) { throw new InvalidOperationException("No document serializer has been configured for event store."); } IDocumentStoreFactory docStoreFactory = new FileDocumentStoreFactory(baseDir, documentSerializer); cfg.Set(DocumentStoreFactory_SettingsKey, docStoreFactory); return(cfg); }