Пример #1
0
 /// <summary>
 /// .ctor
 /// </summary>
 /// <param name="queryPipeline">Query pipeline.</param>
 /// <param name="messageContext">Message context.</param>
 public QueryCaller(QueryPipeline queryPipeline, IMessageContext messageContext)
 {
     this.query          = null;
     this.queryPipeline  = queryPipeline;
     this.messageContext = messageContext;
     this.invokeQuery    = true;
 }
Пример #2
0
 /// <summary>
 /// .ctor
 /// </summary>
 /// <param name="queryPipeline">Query pipeline.</param>
 /// <param name="messageContext">Message context.</param>
 /// <param name="query">Query object.</param>
 public QueryCaller(QueryPipeline queryPipeline, IMessageContext messageContext, TQuery query)
     : this(queryPipeline, messageContext)
 {
     if (query == null)
     {
         throw new ArgumentNullException(nameof(query));
     }
     this.query = query;
 }
        /// <summary>
        /// Add query pipeline feature to message context.
        /// </summary>
        /// <param name="messagePipelineContainer">Pipeline container.</param>
        /// <param name="setupAction">Action to setup query pipeline.</param>
        /// <returns>Query pipeline builder.</returns>
        public static QueryPipelineBuilder AddQueryPipeline(this IMessagePipelineContainer messagePipelineContainer,
                                                            Action <QueryPipelineOptions> setupAction)
        {
            if (messagePipelineContainer.Pipelines.Any(p => p is IQueryPipeline))
            {
                throw new InvalidOperationException("Queries pipeline already exists in global context items. " +
                                                    "Use RemovePipeline method to clean up existins pipeline.");
            }

            var queryPipeline = new QueryPipeline();

            setupAction(queryPipeline.Options);
            var list = messagePipelineContainer.Pipelines.ToList();

            list.Add(queryPipeline);
            messagePipelineContainer.Pipelines = list.ToArray();

            return(new QueryPipelineBuilder(queryPipeline));
        }