public void GetInstance()
        {
            //Arrange
            var name = typeof(FooComponent).Name;

            _components.Add(name, new FooComponent());

            //Act
            var result = _target.GetInstance <IAsyncPipelineComponent <TestPayload> >(name);

            //Assert
            result.Should().NotBeNull();
            result.Should().BeAssignableTo <FooComponent>();
        }
コード例 #2
0
        /// <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);
            });
        }
コード例 #3
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;
        }