當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。