Ejemplo n.º 1
0
        internal ActiveSagaInstance(Saga saga, SagaMetadata metadata, Func<DateTime> currentUtcDateTimeProvider)
        {
            this.currentUtcDateTimeProvider = currentUtcDateTimeProvider;
            Instance = saga;
            Metadata = metadata;

            Created = currentUtcDateTimeProvider();
            Modified = Created;
        }
        public static SagaMetadata Create(Type sagaType, IEnumerable <Type> availableTypes, Conventions conventions)
        {
            if (!IsSagaType(sagaType))
            {
                throw new Exception(sagaType.FullName + " is not a saga");
            }

            var sagaEntityType = sagaType.BaseType.GetGenericArguments().Single();

            var uniquePropertiesOnEntity = FindUniqueAttributes(sagaEntityType).ToList();

            var mapper = new SagaMapper();

            var saga = (Saga)FormatterServices.GetUninitializedObject(sagaType);

            saga.ConfigureHowToFindSaga(mapper);

            ApplyScannedFinders(mapper, sagaEntityType, availableTypes, conventions);


            var finders = new List <SagaFinderDefinition>();

            foreach (var mapping in mapper.Mappings)
            {
                if (uniquePropertiesOnEntity.All(p => p.Name != mapping.SagaPropName))
                {
                    uniquePropertiesOnEntity.Add(new CorrelationProperty {
                        Name = mapping.SagaPropName
                    });
                }


                SetFinderForMessage(mapping, sagaEntityType, finders);
            }

            var associatedMessages = GetAssociatedMessages(sagaType)
                                     .ToList();

            var metadata = new SagaMetadata(associatedMessages, finders)
            {
                Name                  = sagaType.FullName,
                EntityName            = sagaEntityType.FullName,
                CorrelationProperties = uniquePropertiesOnEntity,
                SagaEntityType        = sagaEntityType,
                SagaType              = sagaType
            };

            return(metadata);
        }
Ejemplo n.º 3
0
 internal ActiveSagaInstance(Saga saga, SagaMetadata metadata)
 {
     Instance = saga;
     Metadata = metadata;
 }
Ejemplo n.º 4
0
 internal ActiveSagaInstance(Saga saga,SagaMetadata metadata)
 {
     Instance = saga;
     Metadata = metadata;
 }