private void EnsureStrategyFactory()
 {
     if (_factoryContainer == null)
     {
         _factoryContainer = new MessageHandlingStrategyFactoryContainer <TMessage, TProjection>();
         _configurer(_factoryContainer);
     }
 }
Пример #2
0
        /// <summary>
        ///     Translate a message into a series of other messages.
        /// </summary>
        public static IMessageHandlingStrategyConfiguration <TR, TProjection> Translate <TMessage, TProjection, TR>(
            this IMessageHandlingStrategyConfiguration <TMessage, TProjection> source,
            Func <TMessage, IEnumerable <TR> > translate
            ) where TProjection : class, new()
        {
            var container = new MessageHandlingStrategyFactoryContainer <TR, TProjection>();

            ((IContainMessageHandlingStrategyFactory <TMessage, TProjection>)source).SetFactory(() =>
            {
                IMessageHandlingStrategy <TR> strategy = container.Create();
                return(new TranslateStrategy <TMessage, TR>(translate, strategy));
            });
            return(container);
        }