public ObjectDef RepositoryFor(SagaTypes sagaTypes)
        {
            if (sagaTypes.StateType.GetProperty(SagaTypes.Id) == null)
            {
                return null;
            }

            var objectDef = new ObjectDef(typeof (InMemorySagaRepository<,>), sagaTypes.StateType, sagaTypes.MessageType);

            objectDef.DependencyByValue(typeof(Func<,>).MakeGenericType(sagaTypes.StateType, typeof(Guid)), sagaTypes.ToSagaIdFunc());
            objectDef.DependencyByValue(typeof(Func<,>).MakeGenericType(sagaTypes.MessageType, typeof(Guid)), sagaTypes.ToCorrelationIdFunc());

            return objectDef;
        }
        public Instance RepositoryFor(SagaTypes sagaTypes)
        {
            if (sagaTypes.StateType.GetProperty(SagaTypes.Id) == null)
            {
                return null;
            }

            var instance = new ConfiguredInstance(typeof (InMemorySagaRepository<,>), sagaTypes.StateType, sagaTypes.MessageType);
            instance.Dependencies.Add(typeof(Func<,>).MakeGenericType(sagaTypes.StateType, typeof(Guid)), sagaTypes.ToSagaIdFunc());
            instance.Dependencies.Add(typeof(Func<,>).MakeGenericType(sagaTypes.MessageType, typeof(Guid)), sagaTypes.ToCorrelationIdFunc());


            return instance;
        }
Exemple #3
0
        public void saga_types_being_able_to_gimme_an_id_getter_for_the_state_object()
        {
            var types = new SagaTypes
            {
                MessageType = typeof(SagaMessageOne),
                StateType   = typeof(MySagaState)
            };

            var func = types.ToSagaIdFunc().ShouldBeOfType <Func <MySagaState, Guid> >();

            var state = new MySagaState
            {
                Id = Guid.NewGuid()
            };

            func(state).ShouldBe(state.Id);
        }
        public void saga_types_being_able_to_gimme_an_id_getter_for_the_state_object()
        {
            var types = new SagaTypes
            {
                MessageType = typeof(SagaMessageOne),
                StateType = typeof(MySagaState)
            };

            var func = types.ToSagaIdFunc().ShouldBeOfType<Func<MySagaState, Guid>>();

            var state = new MySagaState
            {
                Id = Guid.NewGuid()
            };

            func(state).ShouldBe(state.Id);
        }
        public static InMemorySagaRepository <TState, TMessage> Create()
        {
            var types = new SagaTypes
            {
                StateType   = typeof(TState),
                MessageType = typeof(TMessage)
            };

            return(new InMemorySagaRepository <TState, TMessage>((Func <TMessage, Guid>)types.ToCorrelationIdFunc(), (Func <TState, Guid>)types.ToSagaIdFunc(), new SagaStateCacheFactory()));
        }
        public Instance RepositoryFor(SagaTypes sagaTypes)
        {
            if (sagaTypes.StateType.GetProperty(SagaTypes.Id) == null)
            {
                return(null);
            }

            var instance = new ConfiguredInstance(typeof(InMemorySagaRepository <,>), sagaTypes.StateType, sagaTypes.MessageType);

            instance.Dependencies.Add(typeof(Func <,>).MakeGenericType(sagaTypes.StateType, typeof(Guid)), sagaTypes.ToSagaIdFunc());
            instance.Dependencies.Add(typeof(Func <,>).MakeGenericType(sagaTypes.MessageType, typeof(Guid)), sagaTypes.ToCorrelationIdFunc());


            return(instance);
        }
        public ObjectDef RepositoryFor(SagaTypes sagaTypes)
        {
            if (sagaTypes.StateType.GetProperty(SagaTypes.Id) == null)
            {
                return(null);
            }

            var objectDef = new ObjectDef(typeof(InMemorySagaRepository <,>), sagaTypes.StateType, sagaTypes.MessageType);

            objectDef.DependencyByValue(typeof(Func <,>).MakeGenericType(sagaTypes.StateType, typeof(Guid)), sagaTypes.ToSagaIdFunc());
            objectDef.DependencyByValue(typeof(Func <,>).MakeGenericType(sagaTypes.MessageType, typeof(Guid)), sagaTypes.ToCorrelationIdFunc());

            return(objectDef);
        }