Esempio n. 1
0
        public void BuildGetPipeline()
        {
            var builder  = PipelineBuilder.Get(GetSource(), new PSRuleOption());
            var pipeline = builder.Build();

            Assert.NotNull(pipeline);
        }
Esempio n. 2
0
        private void PrepareGetPipeline()
        {
            var option = new PSRuleOption();

            option.Rule.Include = new string[] { "Benchmark" };
            var builder = PipelineBuilder.Get(GetSource(), option);

            _GetPipeline = builder.Build();
        }
Esempio n. 3
0
        public void RunPipeline <TPipelineMessage>(TPipelineMessage message) where TPipelineMessage : class, IPipelineMessage
        {
            Log("PieplineMessage", message);

            var pipelines = _factory.GetPipelines(message);

            if (!pipelines.Any())
            {
                return;
            }

            if (pipelines.Count > 1)
            {
                throw new MultiplePipelinesException($"{pipelines.Count} Pipelines found for {message.GetType().Name}");
            }

            dynamic thisPipeline = pipelines.First();

            var builder = new PipelineBuilder <TPipelineMessage>();

            thisPipeline.GetPipelineTasks(builder);

            var taskTypes = builder.Get().ToList();

            if (!taskTypes.Any())
            {
                return;
            }

            var tasks = taskTypes.Select(t => (IPipelineTask <TPipelineMessage>)_factory.GetPipelineHandler(t)).ToList();

            for (var i = 0; i < tasks.Count - 1; i++)
            {
                var thisTask = tasks[i];
                var nextTask = tasks[i + 1];

                thisTask.Setup(nextTask.Run);
            }

            // Noop last task
            tasks.Last().Setup(m => { });

            // Run pipeline
            tasks.First().Run(message);
        }