/// <summary> /// Creates new instance with enumeration of supported methods in <paramref name="supportedMethod"/>. Other methods are empty. /// If one of stores required by <paramref name="supportedMethod"/> is <c>null</c>, this method is automatically not supported. /// </summary> /// <param name="supportedMethod">The enumeration of supported methods.</param> /// <param name="store">The store for loading and saving events.</param> /// <param name="publishingStore">The store for saving delivery information.</param> /// <param name="rebuilderStore">The store for rebuilding read-models.</param> public EmptyEventStore(Method supportedMethod, IEventStore store, IEventPublishingStore publishingStore, IEventRebuilderStore rebuilderStore) { this.supportedMethod = supportedMethod; this.store = store; this.publishingStore = publishingStore; this.rebuilderStore = rebuilderStore; if (store == null) { supportedMethod &= Method.Get; supportedMethod &= Method.GetWithVersion; supportedMethod &= Method.Save; } if (publishingStore == null) { supportedMethod &= Method.GetUnpublished; supportedMethod &= Method.Clear; supportedMethod &= Method.Publish; } if (rebuilderStore == null) { supportedMethod &= Method.GetOfTypes; } }
/// <summary> /// Creates new instance. /// </summary> /// <param name="store">The publishing store for command persistent delivery.</param> /// <param name="schedulingProvider">The provider of a delay computation for delayed events.</param> public PersistentEventDispatcher(IEventPublishingStore store, ISchedulingProvider schedulingProvider) { Ensure.NotNull(store, "store"); Ensure.NotNull(schedulingProvider, "schedulingProvider"); this.store = store; this.schedulingProvider = schedulingProvider; EventExceptionHandlers = new DefaultExceptionHandlerCollection(); DispatcherExceptionHandlers = new DefaultExceptionHandlerCollection(); this.descriptorProvider = new HandlerDescriptorProvider( typeof(IEventHandler <>), typeof(IEventHandlerContext <>), TypeHelper.MethodName <IEventHandler <object>, object, Task>(h => h.HandleAsync), EventExceptionHandlers, DispatcherExceptionHandlers ); Handlers = new HandlerCollection(storage, descriptorProvider); }
/// <summary> /// Creates new instance. /// </summary> /// <param name="store">A publishing store for command persistent delivery.</param> /// <param name="schedulingProvider">A provider of a delay computation for delayed events.</param> public PersistentEventDispatcher(IEventPublishingStore store, ISchedulingProvider schedulingProvider) : this(store, schedulingProvider, new DefaultLogFactory()) { }
/// <summary> /// Creates new instance. /// </summary> /// <param name="store">The publishing store for command persistent delivery.</param> public PersistentEventDispatcher(IEventPublishingStore store) : this(store, new TimerSchedulingProvider(new TimerSchedulingProvider.DateTimeNowProvider())) { }