Exemplo n.º 1
0
        public Guid Generate(SagaIdGeneratorContext context)
        {
            if (context.CorrelationProperty == SagaCorrelationProperty.None)
            {
                throw new Exception("The CosmosDB saga persister doesn't support custom saga finders.");
            }

            return(CosmosSagaIdGenerator.Generate(context.SagaMetadata.SagaEntityType, context.CorrelationProperty.Name, context.CorrelationProperty.Value));
        }
        public Guid Generate(SagaIdGeneratorContext context)
        {
            if (context.CorrelationProperty == SagaCorrelationProperty.None)
            {
                return(Guid.NewGuid());
            }

            var sagaInfo = sagaInfoCache.GetInfo(context.SagaMetadata.SagaEntityType);

            return(Generate(sagaInfo, context.CorrelationProperty.Name, context.CorrelationProperty.Value));
        }
        IContainSagaData CreateNewSagaEntity(SagaMetadata metadata, IInvokeHandlerContext context)
        {
            var sagaEntityType = metadata.SagaEntityType;

            var sagaEntity = (IContainSagaData)Activator.CreateInstance(sagaEntityType);

            sagaEntity.OriginalMessageId = context.MessageId;

            string replyToAddress;

            if (context.Headers.TryGetValue(Headers.ReplyToAddress, out replyToAddress))
            {
                sagaEntity.Originator = replyToAddress;
            }

            var lookupValues = context.Extensions.GetOrCreate <SagaLookupValues>();

            SagaCorrelationProperty correlationProperty;

            SagaLookupValues.LookupValue value;

            if (lookupValues.TryGet(sagaEntityType, out value))
            {
                var propertyInfo = sagaEntityType.GetProperty(value.PropertyName);

                var convertedValue = TypeDescriptor.GetConverter(propertyInfo.PropertyType)
                                     .ConvertFromInvariantString(value.PropertyValue.ToString());

                propertyInfo.SetValue(sagaEntity, convertedValue);

                correlationProperty = new SagaCorrelationProperty(value.PropertyName, value.PropertyValue);
            }
            else
            {
                correlationProperty = SagaCorrelationProperty.None;
            }

            var sagaIdGeneratorContext = new SagaIdGeneratorContext(correlationProperty, metadata, context.Extensions);

            sagaEntity.Id = sagaIdGenerator.Generate(sagaIdGeneratorContext);

            return(sagaEntity);
        }
 public Guid Generate(SagaIdGeneratorContext context)
 {
     // intentionally ignore the property name and the value.
     return(CombGuid.Generate());
 }
 public Guid Generate(SagaIdGeneratorContext context)
 {
     return(ToGuid($"{context.SagaMetadata.SagaEntityType.FullName}_{context.CorrelationProperty.Name}_{context.CorrelationProperty.Value}"));
 }
Exemplo n.º 6
0
 public Guid Generate(SagaIdGeneratorContext context)
 {
     return(CombGuid.Generate());
 }