コード例 #1
0
        /// <summary>
        /// Use data contract XML for document serialization.
        /// </summary>
        /// <param name="cfg"></param>
        /// <returns></returns>
        public static EventStoreConfiguration WithDataContractDocumentSerializer(this EventStoreConfiguration cfg)
        {
            IDocumentSerializer serializer = new DataContractDocumentSerializer();

            Xyperico.Agres.EventStore.EventStoreConfigurationExtensions.SetDocumentSerializer(cfg, serializer);
            return(cfg);
        }
コード例 #2
0
        public static void SetAppendOnlyStore(EventStoreConfiguration cfg, IAppendOnlyStore store)
        {
            if (cfg.ContainsKey(AppendOnlyStore_SettingsKey))
            throw new InvalidOperationException("You should not configure append-only back-end store for event store twice.");

              Condition.Requires(cfg, "cfg").IsNotNull();
              Condition.Requires(store, "store").IsNotNull();
              cfg.Set(AppendOnlyStore_SettingsKey, store);
              Logger.DebugFormat("Using {0} as storage engine for EventStore", store);
        }
コード例 #3
0
        public static void SetEventPublisher(EventStoreConfiguration cfg, IEventPublisher publisher)
        {
            if (cfg.ContainsKey(DocumentSerializer_SettingsKey))
            {
                throw new InvalidOperationException("You should not configure event publisher for event store twice.");
            }

            Condition.Requires(cfg, "cfg").IsNotNull();
            Condition.Requires(publisher, "publisher").IsNotNull();
            cfg.Set(EventPublisher_SettingsKey, publisher);
        }
コード例 #4
0
        public static void SetMessageSerializer(EventStoreConfiguration cfg, ISerializer serializer)
        {
            if (cfg.ContainsKey(MessageSerializer_SettingsKey))
            {
                throw new InvalidOperationException("You should not configure message serializer for event store twice.");
            }

            Condition.Requires(cfg, "cfg").IsNotNull();
            Condition.Requires(serializer, "serializer").IsNotNull();
            cfg.Set(MessageSerializer_SettingsKey, serializer);
            Logger.DebugFormat("Using {0} as serializer for messages in event store", serializer);
        }
コード例 #5
0
        public static void SetAppendOnlyStore(EventStoreConfiguration cfg, IAppendOnlyStore store)
        {
            if (cfg.ContainsKey(AppendOnlyStore_SettingsKey))
            {
                throw new InvalidOperationException("You should not configure append-only back-end store for event store twice.");
            }

            Condition.Requires(cfg, "cfg").IsNotNull();
            Condition.Requires(store, "store").IsNotNull();
            cfg.Set(AppendOnlyStore_SettingsKey, store);
            Logger.DebugFormat("Using {0} as storage engine for EventStore", store);
        }
コード例 #6
0
        /// <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);
        }
コード例 #7
0
        /// <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));
        }
コード例 #8
0
        public static void SetDocumentSerializer(EventStoreConfiguration cfg, IDocumentSerializer serializer)
        {
            if (cfg.ContainsKey(DocumentSerializer_SettingsKey))
            throw new InvalidOperationException("You should not configure document serializer for event store twice.");

              Condition.Requires(cfg, "cfg").IsNotNull();
              Condition.Requires(serializer, "serializer").IsNotNull();
              cfg.Set(DocumentSerializer_SettingsKey, serializer);
        }
コード例 #9
0
        public static void SetMessageSerializer(EventStoreConfiguration cfg, ISerializer serializer)
        {
            if (cfg.ContainsKey(MessageSerializer_SettingsKey))
            throw new InvalidOperationException("You should not configure message serializer for event store twice.");

              Condition.Requires(cfg, "cfg").IsNotNull();
              Condition.Requires(serializer, "serializer").IsNotNull();
              cfg.Set(MessageSerializer_SettingsKey, serializer);
              Logger.DebugFormat("Using {0} as serializer for messages in event store", serializer);
        }