• NServiceBus-容器


    NServiceBus自动注册以及用户实现其所有组件处理程序和传奇,这样所有实例化模式和连接在默认情况下都是正确的,没有错误。

    NServiceBus在容器构建(目前Autofac的ilmerge版本),但它可以取代任何其他容器。

    获得其他容器

    nuget其他容器可用。

    配置NServiceBus使用其他容器

    • v5
    • V4

      编辑

      var configuration = new BusConfiguration();
      
      // Autofac
      configuration.UseContainer<AutofacBuilder>();
      // Autofac with a container instance
      configuration.UseContainer<AutofacBuilder>(c => c.ExistingLifetimeScope(lifetimeScope));
      
      // Castle
      configuration.UseContainer<WindsorBuilder>();
      // Castle with a container instance
      configuration.UseContainer<WindsorBuilder>(c => c.ExistingContainer(windsorContainer));
      
      // Ninject
      configuration.UseContainer<NinjectBuilder>();
      // Ninject with a container instance 
      configuration.UseContainer<NinjectBuilder>(c => c.ExistingKernel(ninjectKernel));
      
      // Unity
      configuration.UseContainer<UnityBuilder>();
      // Unity with a container instance 
      configuration.UseContainer<UnityBuilder>(c => c.UseExistingContainer(unityContainer));
      
      // Spring
      configuration.UseContainer<SpringBuilder>();
      // Spring with an instance 
      configuration.UseContainer<SpringBuilder>(c => c.ExistingApplicationContext(springApplicationContext));
      
      // StructureMap
      configuration.UseContainer<StructureMapBuilder>();
      // StructureMap with a container instance 
      configuration.UseContainer<StructureMapBuilder>(c => c.ExistingContainer(structureMapContainer));
      

      插入自己的容器

      • v5
      • V4

        编辑

        public void CustomContainerExtensionUsage()
        {
            var configuration = new BusConfiguration();
            //Register the container in the configuration with '.UseContainer<T>()'
            configuration.UseContainer<MyContainer>();
        }
        // Create a class that implements 'ContainerDefinition' and returns your 'IContainer' implementation.
        public class MyContainer : ContainerDefinition
        {
            public override IContainer CreateContainer(ReadOnlySettings settings)
            {
                return new MyObjectBuilder();
            }
        }
        //Create a class that implements 'IContainer'
        public class MyObjectBuilder : IContainer
        {
    • 相关阅读:
      LeetCode 链表题总结
      分布式系统 MIT 6.824 Lab 1: MapReduce 准备
      Consul 入门(二)
      Consul 入门
      IDEA批量修改变量快捷键
      Spring源码解析-JdbcTemplate
      SpringMVC源码解析-HTTP请求处理和分发
      SpringMVC源码解析-DispatcherServlet启动流程和初始化
      发现一个网站可以看英文版的harry potter小说,好东西分享一下哈
      TypeSrcript如何引入第三方库 如果加d.ts以及async await如何使用 demo,只有代码,文字后续补充
    • 原文地址:https://www.cnblogs.com/powerxu/p/4294306.html
    • Copyright © 2020-2023  润新知