Exemplo n.º 1
0
        public void Save(EventStream eventStream, Action <EventEnvelopeConfigurator> configure)
        {
            Guard.AgainstNull(eventStream, nameof(eventStream));

            if (eventStream.Removed)
            {
                Remove(eventStream.Id);

                return;
            }

            if (!eventStream.ShouldSave())
            {
                return;
            }

            var pipeline = _pipelineFactory.GetPipeline <SaveEventStreamPipeline>();

            try
            {
                var configurator = new EventEnvelopeConfigurator();

                configure?.Invoke(configurator);

                pipeline.Execute(eventStream, configurator);
            }
            finally
            {
                _pipelineFactory.ReleasePipeline(pipeline);
            }
        }
        public void Execute(EventStream eventStream, EventEnvelopeConfigurator configurator)
        {
            Guard.AgainstNull(eventStream, nameof(eventStream));

            State.SetEventStream(eventStream);
            State.SetEventEnvelopeConfigurator(configurator);

            Execute();
        }
 public static void SetEventEnvelopeConfigurator(this IState state, EventEnvelopeConfigurator value)
 {
     state.Replace(StateKeys.EventEnvelopeConfigurator, value);
 }