Exemplo n.º 1
0
        public static SagaConfiguration <TSaga, TState> State <TSaga, TState, TFactory, TStartMessage>(ISagaDescriptor descriptor,
                                                                                                       Func <ISnapshotsPersistencePolicy> snapShotsPolicy = null,
                                                                                                       Func <IMemento, TState> snapshotsConstructor       = null)
            where TFactory : ISagaFactory <TSaga, TState>,
        ISagaFactory <TSaga, TStartMessage>,
        new()

            where TSaga : class, ISagaInstance
            where TState : AggregateBase
        {
            var producer = new SagaProducer <TSaga>(descriptor);
            var factory  = new TFactory();

            producer.Register <TState>(factory);
            producer.Register <TStartMessage>(factory);

            return(new SagaConfiguration <TSaga, TState>(producer, snapShotsPolicy, snapshotsConstructor));
        }
Exemplo n.º 2
0
        public static SagaConfiguration <ISagaInstance <TSaga, TData>, SagaDataAggregate <TData> > Instance <TSaga, TData, TFactory, TStartMessageA, TStartMessageB>
            (ISagaDescriptor descriptor, Func <ISnapshotsPersistencePolicy> snapShotsPolicy = null, Func <IMemento, SagaDataAggregate <TData> > stateConstructor = null)
            where TSaga : Saga <TData>
            where TData : class, ISagaState
            where TFactory : ISagaFactory <ISagaInstance <TSaga, TData>, SagaDataAggregate <TData> >,
        ISagaFactory <ISagaInstance <TSaga, TData>, TStartMessageA>,
        ISagaFactory <ISagaInstance <TSaga, TData>, TStartMessageB>,
        new()
        {
            var producer = new SagaProducer <ISagaInstance <TSaga, TData> >(descriptor);
            var factory  = new TFactory();

            producer.Register <TStartMessageA>(factory);
            producer.Register <TStartMessageB>(factory);
            producer.Register <SagaDataAggregate <TData> >(factory);
            stateConstructor = stateConstructor ?? SagaDataAggregate <TData> .FromSnapshot;

            return(new SagaConfiguration <ISagaInstance <TSaga, TData>, SagaDataAggregate <TData> >(producer, snapShotsPolicy, stateConstructor));
        }