예제 #1
0
        public Frame DeterminePersistenceFrame(IContainer container, HandlerChain chain, MethodCall sagaHandler,
                                               SagaStateExistence existence,
                                               ref Variable sagaId, Type sagaStateType,
                                               Variable existingState, out Variable loadedState)
        {
            var frame = new TransactionalFrame();

            if (existence == SagaStateExistence.Existing)
            {
                var doc = frame.LoadDocument(sagaStateType, sagaId);
                loadedState = doc;
            }
            else
            {
                var mapping = new DocumentMapping(sagaStateType, new StoreOptions());

                sagaId = new Variable(mapping.IdMember.GetMemberType(),
                                      existingState.Usage + "." + mapping.IdMember.Name);


                loadedState = existingState;
            }

            return(frame);
        }
        protected override Frame buildPersistenceFrame(IContainer container, HandlerChain chain,
                                                       SagaStateExistence existence, ref Variable sagaId, Type sagaStateType,
                                                       Variable existingState,
                                                       ref Variable loadedState)
        {
            var dbContextType = DetermineDbContextType(chain, container);

            var frame = new TransactionalFrame(dbContextType);

            if (existence == SagaStateExistence.Existing)
            {
                var doc = frame.LoadDocument(sagaStateType, sagaId);
                loadedState = doc;
            }
            else
            {
                var property = findIdProperty(sagaStateType);
                sagaId = new Variable(property.PropertyType,
                                      existingState.Usage + "." + property.Name);


                frame.InsertEntity(existingState);

                loadedState = existingState;
            }

            return(frame);
        }
예제 #3
0
        public InMemorySagaPersistenceFrame(Type documentType, Variable sagaId, SagaStateExistence existence)
        {
            _sagaId    = sagaId;
            _existence = existence;
            Document   = new Variable(documentType, this);

            Persistor = new Variable(typeof(InMemoryEnvelopeTransaction), this);
        }
예제 #4
0
        public void determine_saga_existence_from_handler_call(string methodName, SagaStateExistence existence)
        {
            var method = typeof(FooSaga).GetMethod(methodName);
            var @call  = new HandlerCall(typeof(FooSaga), method);

            SagaFramePolicy.DetermineExistence(@call)
            .ShouldBe(existence);
        }
예제 #5
0
        protected override Frame buildPersistenceFrame(SagaStateExistence existence, Variable sagaId, Type sagaStateType,
                                                       ref Variable loadedState)
        {
            var frame = new InMemorySagaPersistenceFrame(sagaStateType, sagaId, existence);

            if (existence == SagaStateExistence.Existing)
            {
                loadedState = frame.Document;
            }

            return(frame);
        }
예제 #6
0
        public Frame DeterminePersistenceFrame(MethodCall sagaHandler, SagaStateExistence existence,
                                               ref Variable sagaId, Type sagaStateType,
                                               Variable existingState, out Variable loadedState)
        {
            loadedState = existingState;
            if (existence == SagaStateExistence.New)
            {
                var prop = findIdProperty(sagaStateType);
                sagaId = new Variable(prop.PropertyType, existingState.Usage + "." + prop.Name);
            }

            var frame = buildPersistenceFrame(existence, sagaId, sagaStateType, ref loadedState);

            return(frame);
        }
예제 #7
0
        public Frame DeterminePersistenceFrame(SagaStateExistence existence, ref Variable sagaId, Type sagaStateType,
                                               Variable existingState, out Variable loadedState)
        {
            loadedState = existingState;
            if (existence == SagaStateExistence.New)
            {
                var prop = FindIdProperty(sagaStateType);
                sagaId = new Variable(prop.PropertyType, existingState.Usage + "." + prop.Name);
            }

            var frame = new InMemorySagaPersistenceFrame(sagaStateType, sagaId, existence);

            if (existence == SagaStateExistence.Existing)
            {
                loadedState = frame.Document;
            }

            return(frame);
        }
예제 #8
0
 protected override Frame buildPersistenceFrame(SagaStateExistence existence, Variable sagaId, Type sagaStateType,
                                                ref Variable loadedState)
 {
     throw new NotImplementedException();
 }
예제 #9
0
 protected abstract Frame buildPersistenceFrame(SagaStateExistence existence, Variable sagaId,
                                                Type sagaStateType, ref Variable loadedState);
예제 #10
0
 protected abstract Frame buildPersistenceFrame(IContainer container, HandlerChain chain,
                                                SagaStateExistence existence, ref Variable sagaId,
                                                Type sagaStateType, Variable existingState, ref Variable loadedState);