当前位置: 首页>>代码示例>>C#>>正文


C# ContainerBuilder.RegisterComponents方法代码示例

本文整理汇总了C#中Autofac.ContainerBuilder.RegisterComponents方法的典型用法代码示例。如果您正苦于以下问题:C# ContainerBuilder.RegisterComponents方法的具体用法?C# ContainerBuilder.RegisterComponents怎么用?C# ContainerBuilder.RegisterComponents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Autofac.ContainerBuilder的用法示例。


在下文中一共展示了ContainerBuilder.RegisterComponents方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateContainer

 private static IContainer CreateContainer()
 {
     var containerBuilder = new ContainerBuilder();
     containerBuilder.RegisterComponents();
     var container = containerBuilder.Build();
     return container;
 }
开发者ID:sammosampson,项目名称:ReliableSignalRMessaging,代码行数:7,代码来源:EndpointConfig.cs

示例2: Configure

        public static IContainer Configure(string authToken, params Assembly[] assemblies)
        {
            IContainer container = null;

            var builder = new ContainerBuilder();

            builder.RegisterComponents(assemblies.SelectMany(asm => TryGetTypes(asm)))
                // Non-singleton components are registered as per-request.
                .ActivatorData.ConfigurationActions.Add((t, rb) =>
                {
                    // We know we have the ComponentAttribute since this is the result of RegisterComponents.
                    if (!rb.ActivatorData.ImplementationType.GetCustomAttributes(true).OfType<ComponentAttribute>().First().IsSingleton)
                        rb.InstancePerRequest();
                });

            builder.Register<IGitHubClient>(c =>
                new GitHubClient(
                    new ProductHeaderValue("OctoHook"),
                    new InMemoryCredentialStore(
                        new Credentials(authToken))));

            builder.Register<IApiConnection>(c =>
                new ApiConnection(c.Resolve<IGitHubClient>().Connection));

            container = builder.Build();

            return container;
        }
开发者ID:LeCantaloop,项目名称:OctoHook,代码行数:28,代码来源:ContainerConfiguration.cs

示例3: BuildLocator

        private static IServiceLocator BuildLocator()
        {
            var builder = new ContainerBuilder();
            builder.RegisterComponents(typeof(IFoo).Assembly);

            var container = builder.Build();

            return new AutofacServiceLocator(container);
        }
开发者ID:netfx,项目名称:CommonComposition,代码行数:9,代码来源:AutofacFixture.cs

示例4: CreateRootContext

        private static IComponentContext CreateRootContext()
        {
            var cb = new ContainerBuilder();

            cb.RegisterComponents(typeof(ComponentContext).Assembly);
            cb.RegisterType<BindingFactory>()
                .AsSelf()
                .AsImplementedInterfaces()
                .InstancePerLifetimeScope();

            var context = new ComponentContext(cb.Build());

            return context;
        }
开发者ID:NuPattern,项目名称:CodeFirst,代码行数:14,代码来源:ToolkitBuilderFixture.cs


注:本文中的Autofac.ContainerBuilder.RegisterComponents方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。