public void ConfigureHowToFindSagaWithMessage(Type sagaType, Type messageType, SagaToMessageMap sagaToMessageMap)
        {
            Dictionary<Type, SagaToMessageMap> messageToProperties;
            SagaEntityToMessageToPropertyLookup.TryGetValue(sagaType, out messageToProperties);

            if (messageToProperties == null)
            {
                messageToProperties = new Dictionary<Type, SagaToMessageMap>();
                SagaEntityToMessageToPropertyLookup[sagaType] = messageToProperties;
            }

            messageToProperties[messageType] = sagaToMessageMap;
        }
示例#2
0
        public void ConfigureHowToFindSagaWithMessage(Type sagaType, Type messageType, SagaToMessageMap sagaToMessageMap)
        {
            Dictionary <Type, SagaToMessageMap> messageToProperties;

            SagaEntityToMessageToPropertyLookup.TryGetValue(sagaType, out messageToProperties);

            if (messageToProperties == null)
            {
                messageToProperties = new Dictionary <Type, SagaToMessageMap>();
                SagaEntityToMessageToPropertyLookup[sagaType] = messageToProperties;
            }

            messageToProperties[messageType] = sagaToMessageMap;
        }
示例#3
0
        void IConfigureHowToFindSagaWithMessage.ConfigureMapping <TSagaEntity, TMessage>(Expression <Func <TSagaEntity, object> > sagaEntityProperty, Expression <Func <TMessage, object> > messageExpression)
        {
            var sagaProp = Reflect <TSagaEntity> .GetProperty(sagaEntityProperty, true);

            ThrowIfNotPropertyLambdaExpression(sagaEntityProperty, sagaProp);
            var compiledMessageExpression = messageExpression.Compile();
            var messageFunc = new Func <object, object>(o => compiledMessageExpression((TMessage)o));

            var sagaToMessageMap = new SagaToMessageMap
            {
                MessageProp  = messageFunc,
                SagaPropName = sagaProp.Name
            };

            sagaConfigurationCache.ConfigureHowToFindSagaWithMessage(typeof(TSagaEntity), typeof(TMessage), sagaToMessageMap);
        }
示例#4
0
 static void SetFinderForMessage(SagaToMessageMap mapping, Type sagaEntityType, List <SagaFinderDefinition> finders)
 {
     if (mapping.HasCustomFinderMap)
     {
         finders.Add(new SagaFinderDefinition(typeof(CustomFinderAdapter <,>).MakeGenericType(sagaEntityType, mapping.MessageType), mapping.MessageType, new Dictionary <string, object>
         {
             { "custom-finder-clr-type", mapping.CustomFinderType }
         }));
     }
     else
     {
         finders.Add(new SagaFinderDefinition(typeof(PropertySagaFinder <>).MakeGenericType(sagaEntityType), mapping.MessageType, new Dictionary <string, object>
         {
             { "property-accessor", mapping.MessageProp },
             { "saga-property-name", mapping.SagaPropName }
         }));
     }
 }
        static void SetFinderForMessage(SagaToMessageMap mapping, Type sagaEntityType, List <SagaFinderDefinition> finders)
        {
            var finder = new SagaFinderDefinition
            {
                MessageType = mapping.MessageType.FullName
            };

            if (mapping.CustomFinderType != null)
            {
                finder.Type = typeof(CustomFinderAdapter <,>).MakeGenericType(sagaEntityType, mapping.MessageType);

                finder.Properties["custom-finder-clr-type"] = mapping.CustomFinderType;
            }
            else
            {
                finder.Type = typeof(PropertySagaFinder <>).MakeGenericType(sagaEntityType);
                finder.Properties["property-accessor"]  = mapping.MessageProp;
                finder.Properties["saga-property-name"] = mapping.SagaPropName;
            }

            finders.Add(finder);
        }
示例#6
0
        void CreatePropertyFinder(FeatureConfigurationContext context, Type sagaEntityType, Type messageType, SagaToMessageMap sagaToMessageMap)
        {
            var finderType = typeof(PropertySagaFinder<,>).MakeGenericType(sagaEntityType, messageType);

            context.Container.ConfigureComponent(finderType, DependencyLifecycle.InstancePerCall)
                .ConfigureProperty("SagaToMessageMap", sagaToMessageMap);

            ConfigureFinder(finderType, conventions);
        }