Example #1
0
 protected PipelineBase(
     IPipelineComponentResolver resolver,
     IEnumerable <Type> componentTypes,
     IDictionary <string, IDictionary <string, string> > settings
     ) : this(resolver, componentTypes.Select(x => x.Name), settings)
 {
 }
        /// <summary>
        /// Abstract pipeline ctor.
        /// </summary>
        /// <param name="resolver">Provides <see cref="IPipelineComponent"/> dependency resolution.</param>
        /// <param name="componentNames">Names of the pipeline components that are contained within this pipeline.
        /// Order of names denotes order of component execution in the pipeline.</param>
        /// <param name="settings">Configuration settings for the pipeline and all of it's components.</param>
        protected PipelineBase(
            IPipelineComponentResolver resolver,
            IEnumerable <string> componentNames,
            IDictionary <string, IDictionary <string, string> > settings)
        {
            if (resolver == null)
            {
                throw new ArgumentNullException(nameof(resolver));
            }
            if (componentNames == null)
            {
                throw new ArgumentNullException(nameof(componentNames));
            }

            Components = componentNames.Select(name =>
            {
                IDictionary <string, string> componentSettings = null;
                if (settings != null && settings.ContainsKey(name))
                {
                    componentSettings = settings[name];
                }

                var component = resolver.GetInstance <TComponent>(name);
                component.Initialize(name, componentSettings);
                return(component);
            });
        }
 internal AsyncPipeline(
     IPipelineComponentResolver resolver,
     IEnumerable <Type> componentTypes,
     IDictionary <string, IDictionary <string, string> > settings
     ) : base(resolver, componentTypes, settings)
 {
 }
Example #4
0
 internal Pipeline(
     IPipelineComponentResolver resolver,
     IEnumerable <string> componentNames,
     IDictionary <string, IDictionary <string, string> > settings
     ) : base(resolver, componentNames, settings)
 {
 }
 /// <inheritdoc />
 public AsyncPipeline(
     IPipelineComponentResolver resolver,
     IEnumerable <string> componentNames,
     IDictionary <string, IDictionary <string, string> > settings = null)
     : base(resolver, componentNames, settings)
 {
 }
 /// <inheritdoc />
 public AsyncPipeline(
     IPipelineComponentResolver resolver,
     IEnumerable <Type> componentTypes,
     IDictionary <string, IDictionary <string, string> > settings,
     IAsyncPipelineComponentExecutionStatusReceiver componentExecutionStatusReceiver)
     : base(resolver, componentTypes, settings)
 {
     _componentExecutionStatusReceiver = componentExecutionStatusReceiver;
 }
Example #7
0
        private static async Task InvokePipelineAsync(IPipelineComponentResolver resolver, IDictionary <string, IDictionary <string, string> > settings)
        {
            Console.WriteLine("Executing pipeline asynchronously.\n");

            var payload = new ExamplePipelinePayload();

            using (var pipeline = PipelineBuilder <ExamplePipelinePayload>
                                  .InitializeAsyncPipeline()
                                  .WithComponent <FooComponent>()
                                  .WithComponent <DelayComponent>()
                                  .WithComponent <BarComponent>()
                                  .WithComponentResolver(resolver)
                                  .WithSettings(settings)
                                  .Build())
            {
                payload = await pipeline.ExecuteAsync(payload);
            }

            payload.Messages.ForEach(Console.WriteLine);

            Console.WriteLine("\n");
        }
Example #8
0
        protected PipelineBase(
            IPipelineComponentResolver resolver,
            IEnumerable <string> componentNames,
            IDictionary <string, IDictionary <string, string> > settings)
        {
            var list = new List <TComponent>();

            foreach (var name in componentNames)
            {
                IDictionary <string, string> componentSettings = null;

                if (settings != null && settings.ContainsKey(name))
                {
                    componentSettings = settings[name];
                }

                var component = resolver.GetInstance <TComponent>(name);
                component.Initialize(name, componentSettings);

                list.Add(component);
            }

            Components = list;
        }
Example #9
0
 public ISettingsHolder <TPipeline> WithComponentResolver(IPipelineComponentResolver componentResolver)
 {
     State.ComponentResolver = componentResolver;
     return(this);
 }
 public void Init()
 {
     _components = new Dictionary <string, IPipelineComponent>();
     _target     = new DictionaryPipelineComponentResolver(_components);
 }