コード例 #1
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;
        }
コード例 #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 }
         }));
     }
 }
コード例 #5
0
        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
ファイル: Sagas.cs プロジェクト: ogdenmd/NServiceBus
        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);
        }