Beispiel #1
0
        /// <summary>
        ///     Remove projections.
        /// </summary>
        public static RemoveProjectionStrategyArguments <TMessage, TProjection> Remove <TMessage, TProjection>(
            this IMessageHandlingStrategyConfiguration <TMessage, TProjection> source
            ) where TProjection : class, new()
        {
            var arguments = new RemoveProjectionStrategyArguments <TMessage, TProjection>();

            ((IContainMessageHandlingStrategyFactory <TMessage, TProjection>)source).SetFactory(() =>
            {
                Filters <TMessage> filters = arguments.Filters;
                return(new RemoveProjectionStrategy <TMessage, TProjection>(filters));
            });
            return(arguments);
        }
Beispiel #2
0
        /// <summary>
        ///     Insert a new projection.
        /// </summary>
        public static AddNewProjectionStrategyArguments <TMessage, TProjection> AddNew <TMessage, TProjection>(
            this IMessageHandlingStrategyConfiguration <TMessage, TProjection> source
            ) where TProjection : class, new()
        {
            var arguments = new AddNewProjectionStrategyArguments <TMessage, TProjection>();

            ((IContainMessageHandlingStrategyFactory <TMessage, TProjection>)source).SetFactory(() =>
            {
                Mappers <TMessage, TProjection> mappers = arguments.Mappers;
                return(new AddNewProjectionStrategy <TMessage, TProjection>(mappers));
            });
            return(arguments);
        }
Beispiel #3
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);
        }