Beispiel #1
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);
        }
 private void EnsureStrategy()
 {
     EnsureStrategyFactory();
     _strategy = _strategy ?? _factoryContainer.Create();
 }