Пример #1
0
        protected override void Load(ContainerBuilder builder)
        {
            base.Load(builder);

            builder.RegisterType <Component1>()
            .Named <IAsyncPipelineComponent <ExamplePipelinePayload> >(typeof(Component1).Name);
            builder.RegisterType <Component2>()
            .Named <IAsyncPipelineComponent <ExamplePipelinePayload> >(typeof(Component2).Name);
            builder.RegisterType <Component3>()
            .Named <IAsyncPipelineComponent <ExamplePipelinePayload> >(typeof(Component3).Name);

            builder.RegisterInstance(new Dictionary <string, IDictionary <string, string> >())
            .As <IDictionary <string, IDictionary <string, string> > >();

            builder.Register(context =>
                             PipelineBuilder <ExamplePipelinePayload>
                             .Async()
                             .WithComponent <Component1>()
                             .WithComponent <Component2>()
                             .WithComponent <Component3>()
                             .WithComponentResolver(context.Resolve <IPipelineComponentResolver>())
                             .WithSettings(context.Resolve <IDictionary <string, IDictionary <string, string> > >())
                             .Build())
            .As <IAsyncPipeline <ExamplePipelinePayload> >();
        }
Пример #2
0
        protected override void Load(ContainerBuilder builder)
        {
            base.Load(builder);

            builder.RegisterType <FooComponent>().Named <IPipelineComponent <TestPayload> >(typeof(FooComponent).Name);
            builder.RegisterType <BarComponent>().Named <IPipelineComponent <TestPayload> >(typeof(BarComponent).Name);

            builder.RegisterType <FooComponent>().Named <IAsyncPipelineComponent <TestPayload> >(typeof(FooComponent).Name);
            builder.RegisterType <BarComponent>().Named <IAsyncPipelineComponent <TestPayload> >(typeof(BarComponent).Name);

            builder.RegisterInstance(new Dictionary <string, IDictionary <string, string> >())
            .As <IDictionary <string, IDictionary <string, string> > >();

            builder.Register(context =>
                             PipelineBuilder <TestPayload>
                             .NonAsync()
                             .WithComponent <FooComponent>()
                             .WithComponent <BarComponent>()
                             .WithComponentResolver(context.Resolve <IPipelineComponentResolver>())
                             .WithSettings(context.Resolve <IDictionary <string, IDictionary <string, string> > >())
                             .Build())
            .As <IPipeline <TestPayload> >();

            builder.Register(context =>
                             PipelineBuilder <TestPayload>
                             .Async()
                             .WithComponent <FooComponent>()
                             .WithComponent <BarComponent>()
                             .WithComponentResolver(context.Resolve <IPipelineComponentResolver>())
                             .WithSettings(context.Resolve <IDictionary <string, IDictionary <string, string> > >())
                             .Build())
            .As <IAsyncPipeline <TestPayload> >();
        }
Пример #3
0
 public void TestAsync()
 {
     // Act/Assert
     PipelineBuilder <TestPayload> .Async()
     .Should()
     .BeAssignableTo <IInitialPipelineComponentHolder <IAsyncPipeline <TestPayload>, IAsyncPipelineComponent <TestPayload>, TestPayload> >();
 }
Пример #4
0
        private static async Task InvokePipelineAsync(DictionaryPipelineComponentResolver resolver, Dictionary <string, IDictionary <string, string> > settings)
        {
            var pipeline = PipelineBuilder <ExamplePipelinePayload>
                           .Async()
                           .WithComponent <FooComponent>()
                           .WithComponent <DelayComponent>()
                           .WithComponent <BarComponent>()
                           .WithComponentResolver(resolver)
                           .WithSettings(settings)
                           .Build();

            Console.WriteLine("Executing pipeline asynchronously.");
            var result = await pipeline.ExecuteAsync(new ExamplePipelinePayload(), CancellationToken.None);

            result.Messages.ForEach(Console.WriteLine);
        }
Пример #5
0
        public override void Compose(IServiceRegistry registry)
        {
            //Inheriting from PipelineCompositionRootBase and calling base class Compose method
            //will register the LightInject container implementation of IPipelineComponentResolver automatically.
            base.Compose(registry);

            //Register components
            registry.RegisterAsyncPipelineComponentsFromAssembly(Assembly.GetExecutingAssembly());

            //Register configuration
            registry.RegisterInstance(
                typeof(IDictionary <string, IDictionary <string, string> >), new Dictionary <string, IDictionary <string, string> >());

            //Register pipeline with builder
            registry.RegisterSingleton(factory =>
                                       PipelineBuilder <ExamplePipelinePayload>
                                       .Async()
                                       .WithComponent <Component1>()
                                       .WithComponent <Component2>()
                                       .WithComponent <Component3>()
                                       .WithComponentResolver(factory.GetInstance <IPipelineComponentResolver>())
                                       .WithSettings(factory.GetInstance <IDictionary <string, IDictionary <string, string> > >())
                                       .Build(),
                                       Examples.PipelineNames.PipelineName);

            registry.RegisterSingleton(factory =>
                                       PipelineBuilder <ExamplePipelinePayload>
                                       .Async()
                                       .WithComponent <Component1>()
                                       .WithComponent <Component2>()
                                       .WithComponent <ExceptionComponent>()
                                       .WithComponentResolver(factory.GetInstance <IPipelineComponentResolver>())
                                       .WithNoSettings()
                                       .Build(),
                                       Examples.PipelineNames.ExceptionPipelineName);
        }