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


C# Autofac类代码示例

本文整理汇总了C#中Autofac的典型用法代码示例。如果您正苦于以下问题:C# Autofac类的具体用法?C# Autofac怎么用?C# Autofac使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: Load

        protected override void Load(Autofac.ContainerBuilder builder)
        {
            base.Load(builder);

            builder.Register<IBridgePayWS>(ctx =>
            {
                var moqBridgePayWS = new Mock<IBridgePayWS>();

                moqBridgePayWS.Setup(b => b.CPSGetAccountPackages(It.IsAny<String>(), It.IsAny<String>()))
                    .Returns(MockData.CPSGetAccountPackages());

                moqBridgePayWS.Setup(b => b.CPSGetCurrentAccountPackage(It.IsAny<String>(), It.IsAny<String>()))
                    .Returns(MockData.CPSGetCurrentAccountPackage());

                moqBridgePayWS.Setup(
                    b => b.CPSGetAvailableAddOns(It.IsAny<String>(), It.IsAny<String>(), It.IsAny<String>()))
                    .Returns(MockData.CPSGetAvailableAddOns());

                moqBridgePayWS.Setup(
                    b => b.ListCountries()
                    ).Returns(MockData.ListCountries());

                moqBridgePayWS.Setup(b => b.ListIndustries()).Returns(MockData.ListIndustries());

                moqBridgePayWS.Setup(b => b.CPSGetContactInfo(It.IsAny<String>(), It.IsAny<String>()))
                    .Returns(MockData.CPSGetContactInfo());
                return moqBridgePayWS.Object;
            }).InstancePerHttpRequest();
        }
开发者ID:ni-hao,项目名称:CPS,代码行数:29,代码来源:AutofacRegisterDependencyModule.cs

示例2: RegisterStyleSheetFiles

 public override System.Collections.Generic.IEnumerable<string> RegisterStyleSheetFiles(Autofac.ContainerBuilder containerBuilder, ICmsConfiguration configuration)
 {
     return new[]
         {
             "/file/bcms-blog/Content/Styles/bcms.blog.css"
         };
 }
开发者ID:pmaciulis,项目名称:BetterCMS,代码行数:7,代码来源:BlogModuleDescriptor.cs

示例3: ConfigureContainerBuilder

        protected override void ConfigureContainerBuilder(Autofac.ContainerBuilder builder)
        {
            base.ConfigureContainerBuilder(builder);

            builder.RegisterControllers(typeof(MvcApplication).Assembly);
            builder.RegisterViewModels(typeof(MvcApplication).Assembly);
        }
开发者ID:daszat,项目名称:zetbox,代码行数:7,代码来源:Global.asax.cs

示例4: Load

        protected override void Load(Autofac.ContainerBuilder builder)
        {
            builder.RegisterType<FaceComparer>()
                    .As<FaceComparer>()
                    .WithProperty("FaceAlignmentModelPath", GetAbsolutePath(Properties.Settings.Default.FaceAlignModelFile))
                    .WithProperty("FaceAlignClassifierPath", GetAbsolutePath(Properties.Settings.Default.FaceAlignClassifierFile))
                    .WithProperty("FaceRepositoryPath", GetAbsolutePath(Properties.Settings.Default.FaceRepositoryPath))
                    .WithProperty("IlluminateReferenceFilePath", GetAbsolutePath(Properties.Settings.Default.IlluminateRefFilePath))
                    .PropertiesAutowired();

            if (EnableFaceComparer)
            {
                if (System.IO.Directory.Exists(PersonOfInterestLibraryPath))
                {
                    var personRepository = SuspectsRepositoryManager.LoadFrom(PersonOfInterestLibraryPath);
                    builder.RegisterInstance(personRepository.Peoples)
                        .As<IEnumerable<PersonOfInterest>>()
                        .ExternallyOwned();
                }
            }
            else
            {
                builder.Register(c => new PersonOfInterest[0]).SingleInstance();
                builder.RegisterType<NullRepositoryFaceComparer>()
                       .As<IRepositoryFaceComparer>();
            }
        }
开发者ID:dalinhuang,项目名称:appcollection,代码行数:27,代码来源:FaceProcessingModule.cs

示例5: Load

        protected override void Load(Autofac.ContainerBuilder builder)
        {
            builder.RegisterType<RestApplication>().As<RestApplication, IRestApplication>();
            builder.RegisterType<SoapApplication>().As<SoapApplication, ISoapApplication>();
            builder.RegisterType<CommandConverter>().As<ICommandConverter>();

            SetupExtensibility(builder);
            if (WithDatabase)
                SetupPostgres(builder);
            SetupPatterns(builder);
            SetupSerialization(builder);

            builder.RegisterType<RepositoryAuthentication>().As<IAuthentication>();
            builder.RegisterType<RepositoryPrincipalFactory>().As<IPrincipalFactory>();
            builder.RegisterType<PermissionManager>().As<IPermissionManager>().SingleInstance();

            builder.RegisterType<LogFactory>().As<ILogFactory>().SingleInstance();
            builder.RegisterType<NLogLogger>().As<ILogger>();

            builder.RegisterType(typeof(ProcessingEngine)).As(typeof(IProcessingEngine)).SingleInstance();

            builder.RegisterType<OnContainerBuild>().As<IStartable>();

            base.Load(builder);
        }
开发者ID:nutrija,项目名称:revenj,代码行数:25,代码来源:StandardModule.cs

示例6: ConfigureRequestContainer

        protected override void ConfigureRequestContainer(Autofac.ILifetimeScope existingContainer)
        {
            var builder = new ContainerBuilder();
            builder.RegisterType<IdeastrikeContext>()
                .AsSelf()
                .SingleInstance();

            builder.RegisterType<IdeaRepository>()
                .AsImplementedInterfaces()
                .SingleInstance();

            builder.RegisterType<ActivityRepository>()
                .AsImplementedInterfaces()
                .SingleInstance();

            builder.RegisterType<FeatureRepository>()
                .AsImplementedInterfaces()
                .SingleInstance();

            builder.RegisterType<SettingsRepository>()
                .AsImplementedInterfaces()
                .SingleInstance();

            builder.RegisterType<UserRepository>()
                .AsImplementedInterfaces()
                .SingleInstance();

            builder.RegisterType<ImageRepository>()
                .AsImplementedInterfaces()
                .SingleInstance();

            builder.Update(existingContainer.ComponentRegistry);
        }
开发者ID:janode,项目名称:Ideastrike,代码行数:33,代码来源:IdeastrikeBootstrapper.cs

示例7: RegisterJavaScriptModules

 public override System.Collections.Generic.IEnumerable<JavaScriptModuleDescriptor> RegisterJavaScriptModules(Autofac.ContainerBuilder containerBuilder, ICmsConfiguration configuration)
 {
     return new[]
         {
             blogJavaScriptModuleDescriptor
         };
 }
开发者ID:pmaciulis,项目名称:BetterCMS,代码行数:7,代码来源:BlogModuleDescriptor.cs

示例8: Load

 protected override void Load(Autofac.ContainerBuilder builder)
 {
     base.Load(builder);
     builder.RegisterType<PosixIdentitySource>()
         .AsImplementedInterfaces()
         .InstancePerLifetimeScope();
 }
开发者ID:daszat,项目名称:zetbox,代码行数:7,代码来源:Module.cs

示例9: RegisterApplicationJqService

 /// <summary>
 /// Registers the jq service.
 /// </summary>
 /// <param name="builder">The builder.</param>
 protected static void RegisterApplicationJqService(Autofac.ContainerBuilder builder)
 {
     builder.RegisterType<Miaow.Application.jq.Service.AddSortService>()
     .As<Miaow.Application.jq.Service.IAddSortService>().InstancePerHttpRequest();
     builder.RegisterType<Miaow.Application.jq.Service.ArticleService>()
     .As<Miaow.Application.jq.Service.IArticleService>().InstancePerHttpRequest();
     builder.RegisterType<Miaow.Application.jq.Service.HomeService>()
     .As<Miaow.Application.jq.Service.IHomeService>().InstancePerHttpRequest();
     builder.RegisterType<Miaow.Application.jq.Service.PageService>()
     .As<Miaow.Application.jq.Service.IPageService>().InstancePerHttpRequest();
     builder.RegisterType<Miaow.Application.jq.Service.PicInfoService>()
     .As<Miaow.Application.jq.Service.IPicInfoService>().InstancePerHttpRequest();
     builder.RegisterType<Miaow.Application.jq.Service.SearchService>()
     .As<Miaow.Application.jq.Service.ISearchService>().InstancePerHttpRequest(); ;
     builder.RegisterType<Miaow.Application.jq.Service.SightInfoService>()
     .As<Miaow.Application.jq.Service.ISightInfoService>().InstancePerHttpRequest();
     builder.RegisterType<Miaow.Application.jq.Service.SinaInfoService>()
     .As<Miaow.Application.jq.Service.ISinaInfoService>().InstancePerHttpRequest();
     builder.RegisterType<Miaow.Application.jq.Service.TicketService>()
     .As<Miaow.Application.jq.Service.ITicketService>().InstancePerHttpRequest();
     builder.RegisterType<Miaow.Application.jq.Service.TopClassService>()
     .As<Miaow.Application.jq.Service.ITopClassService>().InstancePerHttpRequest();
     builder.RegisterType<Miaow.Application.jq.Service.VideoInfoService>()
     .As<Miaow.Application.jq.Service.IVideoInfoService>().InstancePerHttpRequest();
 }
开发者ID:JPomichael,项目名称:Miaow,代码行数:29,代码来源:MiaowPreUnionIoc.cs

示例10: Load

 protected override void Load(Autofac.ContainerBuilder builder)
 {
     base.Load(builder);
     builder.RegisterType<HtpasswdIdentitySource>()
         .AsImplementedInterfaces()
         .SingleInstance();
 }
开发者ID:jrgcubano,项目名称:zetbox,代码行数:7,代码来源:HtpasswdIdentitySource.cs

示例11: SetupExtensibility

        private static void SetupExtensibility(Autofac.ContainerBuilder builder, bool withAspects)
        {
            var dynamicProxy = new CastleDynamicProxyProvider();
            var aopRepository = new AspectRepository(dynamicProxy);

            var assemblies = Revenj.Utility.AssemblyScanner.GetAssemblies().Where(it => it.FullName.StartsWith("Revenj."));
            builder.RegisterInstance(new PluginsConfiguration { Assemblies = assemblies });

            builder.RegisterType<SystemInitialization>();
            builder.RegisterType<AutofacObjectFactory>().As<IObjectFactory>().SingleInstance();
            builder.RegisterType<AutofacMefProvider>().As<IExtensibilityProvider>().SingleInstance();
            builder.RegisterGeneric(typeof(PluginRepository<>)).As(typeof(IPluginRepository<>)).SingleInstance();

            builder.RegisterInstance(aopRepository).As<IAspectRegistrator, IAspectComposer, IInterceptorRegistrator>();
            builder.RegisterInstance(dynamicProxy).As<IMixinProvider, IDynamicProxyProvider>();

            if (withAspects)
            {
                foreach (var m in AssemblyScanner.GetAllTypes())
                {
                    if (m.IsPublic && typeof(Autofac.Module).IsAssignableFrom(m) && m.GetConstructor(new Type[0]) != null)
                        builder.RegisterModule((Autofac.Module)Activator.CreateInstance(m));
                }
                builder.RegisterModule(new AspectsModule(aopRepository));
            }
        }
开发者ID:rinmalavi,项目名称:revenj,代码行数:26,代码来源:AutofacConfiguration.cs

示例12: RegisterApplicationJqService

        /// <summary>
        /// Registers the jq service.
        /// </summary>
        /// <param name="builder">The builder.</param>
        protected static void RegisterApplicationJqService(Autofac.ContainerBuilder builder)
        {
            builder.RegisterType<iPow.Application.jq.Service.AddSortService>()
            .As<iPow.Application.jq.Service.IAddSortService>();
            builder.RegisterType<iPow.Application.jq.Service.ArticleService>()
            .As<iPow.Application.jq.Service.IArticleService>();
            builder.RegisterType<iPow.Application.jq.Service.HomeService>()
            .As<iPow.Application.jq.Service.IHomeService>();
            builder.RegisterType<iPow.Application.jq.Service.PageService>()
            .As<iPow.Application.jq.Service.IPageService>();
            builder.RegisterType<iPow.Application.jq.Service.PicInfoService>()
            .As<iPow.Application.jq.Service.IPicInfoService>();
            builder.RegisterType<iPow.Application.jq.Service.SearchService>()
            .As<iPow.Application.jq.Service.ISearchService>();
            builder.RegisterType<iPow.Application.jq.Service.SightInfoService>()
            .As<iPow.Application.jq.Service.ISightInfoService>();
            builder.RegisterType<iPow.Application.jq.Service.SinaInfoService>()
            .As<iPow.Application.jq.Service.ISinaInfoService>();
            builder.RegisterType<iPow.Application.jq.Service.TicketService>()
            .As<iPow.Application.jq.Service.ITicketService>();
            builder.RegisterType<iPow.Application.jq.Service.TopClassService>()
            .As<iPow.Application.jq.Service.ITopClassService>();
            builder.RegisterType<iPow.Application.jq.Service.VideoInfoService>()
            .As<iPow.Application.jq.Service.IVideoInfoService>();

            //add 2012-4-28  JPomichael
            builder.RegisterType<iPow.Application.jq.Service.SightInfoSortService>()
            .As<iPow.Application.jq.Service.ISightInfoSortService>();
            //end
        }
开发者ID:JPomichael,项目名称:IPOW,代码行数:34,代码来源:iPowPreJqIoc.cs

示例13: Register

 protected override void Register(Autofac.ContainerBuilder builder) {
     builder.RegisterType<PlacementFileParser>().As<IPlacementFileParser>();
     builder.RegisterType<StubCacheManager>().As<ICacheManager>();
     builder.RegisterType<StubParallelCacheContext>().As<IParallelCacheContext>();
     builder.RegisterType<InMemoryWebSiteFolder>().As<IWebSiteFolder>()
         .As<InMemoryWebSiteFolder>().InstancePerLifetimeScope();
 }
开发者ID:RasterImage,项目名称:Orchard,代码行数:7,代码来源:PlacementFileParserTests.cs

示例14: Load

 protected override void Load(Autofac.ContainerBuilder builder)
 {
     builder.RegisterAssemblyTypes(Assembly.Load("EF-Learn.DAL"))
          .Where(t => t.Name.EndsWith("Dal"))
          .AsImplementedInterfaces()
         .InstancePerLifetimeScope();
     base.Load(builder);
 }
开发者ID:youtao,项目名称:EF-Learn,代码行数:8,代码来源:DalModule.cs

示例15: ApplicationStartup

        protected override void ApplicationStartup(Autofac.ILifetimeScope container, Nancy.Bootstrapper.IPipelines pipelines)
        {
            CookieBasedSessions.Enable(pipelines);
            base.ApplicationStartup(container, pipelines);

            GlobalHost.DependencyResolver = new AutofacDependencyResolver(container);
            RouteTable.Routes.MapHubs();
        }
开发者ID:qblook,项目名称:Store,代码行数:8,代码来源:Bootstrapper.cs


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