Esempio n. 1
0
        public ISagaConfigurator <TS, TD> UseStateFactory(Func <IMessage, TD> stateFactory)
        {
            var stateType = typeof(TD);
            var factory   = new LambdaSagaStateFactory <TD>(stateFactory);

            var descriptor = ServiceDescriptor.Singleton(typeof(ISagaStateFactory <>).MakeGenericType(stateType), factory);

            this.Services.Replace(descriptor);

            return(this);
        }
Esempio n. 2
0
        public ISagaConfigurator <TS, TD> UseStateFactory <TM>(Func <TM, TD> stateFactory)
            where TM : IMessage
        {
            var messageType = typeof(TM);
            var stateType   = typeof(TD);

            var factoryInterfaceType = typeof(ISagaStateFactory <,>).MakeGenericType(messageType, stateType);
            var factory = new LambdaSagaStateFactory <TM, TD>(stateFactory);

            var descriptor = ServiceDescriptor.Singleton(factoryInterfaceType, factory);

            this.Services.Replace(descriptor);

            return(this);
        }