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


C# IContainer.Configure方法代码示例

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


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

示例1: RegisterQueryHandlers

 //private static void RegisterCommandHandlers(IContainer container)
 //{
 //    container.Configure(x => x.ForConcreteType<AddNewContractorCommandHandler>());
 //    container.Configure(x => x.ForConcreteType<AddNewSiteCommandHandler>());
 //    container.Configure(x => x.ForConcreteType<UpdateContractorCommandHandler>());
 //    //container.Configure(x => x.For<ICommandHandler<AddNewContractorCommand>>().Use<AddNewContractorCommandHandler>());
 //    //container.Configure(x => x.For<ICommandHandler<UpdateContractorCommand>>().Use<UpdateContractorCommandHandler>());
 //    //return container;
 //    // container.ForGenericType(typeof(ICommandHandler<DDD.Provider.Domain.Commands.AddNewContractorCommand>)
 //}
 //private static void RegisterRepositories(IContainer container)
 //{
 //    container.Configure(x => x.ForConcreteType<ContractorRepository>());
 //}
 //public static void RegisterCommandValidators(IContainer container)
 //{
 //    container.Configure(x => x.For<ICommandValidator<AddNewContractorCommand>>().Use<AddNewContractorCommandValidator>());
 //}
 private static void RegisterQueryHandlers(IContainer container)
 {
     container.Configure(x => x.For<IQueryHandler<FindContractorByIdQuery, ContractorDto>>().Use<FindContractorByIdHandler>());
     container.Configure(x => x.For<IQueryHandler<FindContractorByEinQuery, ContractorDto>>().Use<FindContractorByEinQueryHandler>());
     container.Configure(x => x.ForConcreteType<FindContractorByEinQueryHandler>());
     container.Configure(x => x.For<IQueryHandler<CheckIfContractorExistsQuery,bool>>().Use<CheckIfContractorExistsQueryHandler>());
 }
开发者ID:srivelicheti,项目名称:learning-DDD,代码行数:25,代码来源:IocBootstrapper.cs

示例2: LoadAppropriateStoreRegistry

 public static void LoadAppropriateStoreRegistry(IContainer initContainer)
 {
     var store = initContainer.GetInstance<IRRConfiguration>().ContentStore;
     if (store == Configuration.Store.SqlServerStore)
     {
         var sqlAssembly = Assembly.Load("RequestReduce.SqlServer");
         initContainer.Configure(x =>
                                     {
                                         x.For(sqlAssembly.GetType("RequestReduce.SqlServer.IFileRepository"))
                                             .Use(
                                                 sqlAssembly.GetType(
                                                     "RequestReduce.SqlServer.FileRepository"));
                                         var diskStore =
                                             new ConfiguredInstance(
                                                 sqlAssembly.GetType("RequestReduce.SqlServer.SqlServerStore"));
                                         var diskCache =
                                             new ConfiguredInstance(
                                                 sqlAssembly.GetType("RequestReduce.SqlServer.DbDiskCache"));
                                         x.For<LocalDiskStore>().Singleton()
                                             .Use(diskCache);
                                         diskStore.CtorDependency<LocalDiskStore>("fileStore").Is(
                                             initContainer.GetInstance<LocalDiskStore>());
                                         diskStore.CtorDependency<IUriBuilder>("uriBuilder").Is(
                                             initContainer.GetInstance<IUriBuilder>());
                                         diskStore.CtorDependency<IReductionRepository>("reductionRepository").Is(
                                             initContainer.GetInstance<IReductionRepository>());
                                         x.For<IStore>().LifecycleIs(new RRHybridLifecycle())
                                             .Use(diskStore);
                                     });
     }
     else
         initContainer.Configure(x => x.AddRegistry<RRLocalStoreRegistry>());
 }
开发者ID:andrewdavey,项目名称:RequestReduce,代码行数:33,代码来源:RRContainer.cs

示例3: Configure

        public static void Configure(IContainer container)
        {
            container.Configure(c =>
            {
                c.For<IBasketService>().Use<BasketService>();
                c.For<BasketDiscountPolicy>()
                    .Use<RepositoryBasketDiscountPolicy>();

                string connectionString =
                    ConfigurationManager.ConnectionStrings
                    ["CommerceObjectContext"].ConnectionString;
                c.For<BasketRepository>().Use<SqlBasketRepository>()
                    .Ctor<string>().Is(connectionString);
                c.For<DiscountRepository>().Use<SqlDiscountRepository>()
                    .Ctor<string>().Is(connectionString);
                c.For<ProductRepository>().Use<SqlProductRepository>()
                    .Ctor<string>().Is(connectionString);
                c.For<CurrencyProvider>().Use<SqlCurrencyProvider>()
                    .Ctor<string>().Is(connectionString);
            });

            container.Configure(c =>
            {
                c.For<IFormsAuthentication>().Use(new FormsAuthenticationService());
                c.For<IMembershipService>().Use(new AccountMembershipService());
            });
        }
开发者ID:mesta1,项目名称:dli.net_sourcecode,代码行数:27,代码来源:CommerceCodeAsConfiguration.cs

示例4: RegisterDispatcher

        internal TransportConfigurator RegisterDispatcher(IContainer container, bool enableLogs)
        {
            var serviceProvider = container.GetInstance<IServiceProvider>();
            Dispatcher dispatcher = Dispatcher.Create(config =>
            {
                config.SetMessageHandlerMarker(typeof (IMessageHandler<>))
                      .SetServiceLocator(serviceProvider)
                      .EnableHandlingPriority()
                      .AddScanRule(typeof (Namespace_ViewProject).Assembly)
                      .AddScanRule(typeof (Namespace_DomainProject).Assembly);

                if (enableLogs)
                {
                    config.AddInterceptor<CommandMessageLoggingInterceptor>();
                    config.AddInterceptor<EventMessageLoggingInterceptor>();
                }

                return config;
            });

            container.Configure(config => config.For<CommandMessageLoggingInterceptor>().Use<CommandMessageLoggingInterceptor>());
            container.Configure(config => config.For<EventMessageLoggingInterceptor>().Use<EventMessageLoggingInterceptor>());
            container.Configure(config => config.For<Dispatcher>().Singleton().Use(dispatcher));

            return this;
        }
开发者ID:Ontropix,项目名称:whowhat,代码行数:26,代码来源:TransportConfigurator.cs

示例5: ConfigureNHibernateSession

        /// <summary>
        /// Configures the NHibernate session.
        /// </summary>
        /// <param name="configurationProvider">The configuration provider.</param>
        /// <param name="container">The container.</param>
        protected override void ConfigureNHibernateSession( IConfigurationProvider configurationProvider, IContainer container )
        {
            NHibernate.Cfg.Configuration configuration = configurationProvider.Configure ().GetEnumerator ().Current;
            ISessionFactory sessionFactory = configuration.BuildSessionFactory ();

            container.Configure ( x => x.For<ISessionFactory> ().Singleton ().Use ( sessionFactory ) );
            container.Configure (
                x => x.For<ISession> ().LifecycleIs ( new NServiceBusThreadLocalStorageLifestyle () ).Use ( sessionFactory.OpenSession ) );
        }
开发者ID:divyang4481,项目名称:REM,代码行数:14,代码来源:Bootstrapper.cs

示例6: RegisterSettings

        public CoreConfigurator RegisterSettings(IContainer container)
        {
            var settings = SettingsMapper.Map<AppSettings>();
            container.Configure(config => config.For<AppSettings>().Singleton().Use(settings));

            var serviceProvider = new StructureMapServiceProvider(container);
            container.Configure(config => config.For<IServiceProvider>().Singleton().Use(serviceProvider));
            
            return this;
        }
开发者ID:Ontropix,项目名称:whowhat,代码行数:10,代码来源:CoreConfigurator.cs

示例7: ConfigureIocContainer

 public static IContainer ConfigureIocContainer(IContainer container , IEndpointInstance bus)
 {
     container.Configure(x => x.ForSingletonOf<IEndpointInstance>().Use(() => bus));
     //container.Configure(x => x.ForSingletonOf<DomainEventBus>());
     container.Configure(x => x.For<IContainer>().Use(container));
     //container.Configure(x => x.For<ICommandBus>().Use<IocContainerCommandBus>());
     container.Configure(x => x.For<IQueryProcessor>().Use<QueryProcessor>());
     //RegisterCommandHandlers(container);
     //RegisterRepositories(container);
     RegisterQueryHandlers(container);
     RegisterDbContexts(container);
     RegisterServices(container);
     return container;
 }
开发者ID:srivelicheti,项目名称:learning-DDD,代码行数:14,代码来源:IocBootstrapper.cs

示例8: Application_Start

        protected void Application_Start()
        {
            _container = new Container();
            AreaRegistration.RegisterAllAreas();
            _container.Configure(cfg =>
            {
                cfg.AddRegistry(new StandardRegistry());
                cfg.AddRegistry(new LoggingRegistry());
                cfg.AddRegistry(new ControllerRegistry());
                cfg.AddRegistry(new ServiceRegistry());
                cfg.AddRegistry(new DataContextRegistry());
                cfg.AddRegistry(new MvcRegistry());
            });
            _structureMapDependencyResolver = new StructureMapDependencyResolver(() => _container);
            Func<IContainer> containerFactory = () => _structureMapDependencyResolver.CurrentNestedContainer ?? _container;

            DependencyResolver.SetResolver(_structureMapDependencyResolver);
            GlobalConfiguration.Configure(config =>
            {
                WebApiConfig.Register(config, containerFactory);
            });
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
        }
开发者ID:onnorh,项目名称:test,代码行数:25,代码来源:Global.asax.cs

示例9: Register

    public override void Register(IContainer container, List<SiteRoute> routes, ViewEngineCollection viewEngines, ModelBinderDictionary modelBinders, ICollection<Asset> globalAssets)
    {
      container.Configure(x =>
      {
        x.For<IAtomPubService>().Singleton().Add<AtomPubService>();
        
        //this is default controller for all, no name given
        x.For<IController>().Add<AtomPubController>();
      });

      RegisterController<AtomPubController>(container);      
      RegisterRoutes<AtomPubRouteRegistrar>(container, routes);

      //register main site master page
      RegisterPage(container, new Page("Site") 
      { 
        Areas = new[] { "head", "nav", "content", "sidetop", "sidemid", "sidebot", "foot", "tail" },
        SupportedScopes = SupportedScopes.EntireSite | SupportedScopes.Workspace | SupportedScopes.Collection | SupportedScopes.Entry
      });

      //register other pages
      RegisterPage(container, new Page("AtomPubIndex", "Site") 
      { 
        SupportedScopes = SupportedScopes.EntireSite | SupportedScopes.Collection | SupportedScopes.Workspace 
      });
      
      RegisterPage(container, new Page("AtomPubResource", "Site") 
      { 
        SupportedScopes = SupportedScopes.Entry 
      });
    }
开发者ID:erikzaadi,项目名称:atomsitethemes.erikzaadi.com,代码行数:31,代码来源:AtomPubPlugin.cs

示例10: ApplicationStartup

        protected override void ApplicationStartup(IContainer container, IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);
            RavenDbHelper.ConfigureRaven(container);

            container.Configure(x => x.SelectConstructor(() => new FakeNancyModule()));
        }
开发者ID:dineshkummarc,项目名称:Session--15--.NET-Web-Frameworks,代码行数:7,代码来源:BlogBootstrapper.cs

示例11: RegisterInMemoryEventStore

        internal EventStoreConfigurator RegisterInMemoryEventStore(IContainer container)
        {
            var eventStore = new InMemoryEventStore(EventStoreSettings.GetDefault());
            container.Configure(config => config.For<IEventStore>().Singleton().Use(eventStore));

            return this;
        }
开发者ID:Ontropix,项目名称:whowhat,代码行数:7,代码来源:EventStoreConfigurator.cs

示例12: ConfigureContainer

        public void ConfigureContainer()
        {
            Container = new Container();
            Container.Configure(x => x.Scan(scan =>
            {
                scan.TheCallingAssembly();
                scan.WithDefaultConventions();
                scan.LookForRegistries();
            }));

            Container.Configure(c =>
            {
                c.For<LogMessagesRepository>().Singleton().Use(MessagesRepository);
                c.For<LogMessagesListener>().Singleton();
            });
        }
开发者ID:mickdelaney,项目名称:backbone-mvc-sample,代码行数:16,代码来源:Global.asax.cs

示例13: StructureMapServiceRegistry

        public StructureMapServiceRegistry(IContainer container,IConfigurationSettings settings)
        {
            _container = container;
               _container.Configure(x => {
                x.Scan(cfg =>
                            {
                                cfg.AssemblyContainingType(typeof (IDocumentMapper<>));
                                cfg.ConnectImplementationsToTypesClosing(typeof(IDocumentMapper<>));
                            });

                            x.For<HttpContextBase>().HybridHttpOrThreadLocalScoped().Use(()=> new HttpContextWrapper(HttpContext.Current));
                            x.For<ISiteInitializer>().Use<DefaultSiteInitializer>();
                            x.For<IInstaller>().Use<MSSQLInstaller>();

                            x.For<ICMSUserRepository>().Singleton().Use<CMSUserRepository>();
                            x.For<IConnectionManager>().Use<MSSQLConnectionManager>();
                            x.For<IPageRepository>().Singleton().Use<PageRepository>();
                            x.For<IPageService>().Singleton().Use<PageService>();
                            x.For<IFormatting>().Singleton().Use<Formatting>();
                            x.For<IImagingService>().Singleton().Use<ImagingService>();

                            x.For<ICMSAuthentication>().HybridHttpOrThreadLocalScoped().Use((c) => settings.AuthenticationManager );
                            x.For(typeof (ISearchIndexProvider<>)).Use(typeof (SearchIndexProvider<>));
                            x.For<ISettingsRepository>().Singleton().Use<SettingsRepository>();
                            x.For<ICMSAuthorization>().HybridHttpOrThreadLocalScoped().Use((c) => settings.Authorizer);

                        });

               _service = new StructureMapDependencyScope(container);
        }
开发者ID:pmason127,项目名称:AmphiprionCMS,代码行数:30,代码来源:ServiceRegistry.cs

示例14: ConfigureContainer

        public void ConfigureContainer(ServiceConfigurationContext context)
        {
            _container = context.Container;

            _container.Configure(x =>
            {
                x.For<IPayExSettings>().Use(() => PayExSettings.Instance);

                x.For<IOrderNumberGenerator>().Use<OrderNumberGenerator>();
                x.For<IAdditionalValuesFormatter>().Use<AdditionalValuesFormatter>();
                x.For<IFinancialInvoicingOrderLineFormatter>().Use<FinancialInvoicingOrderLineFormatter>();
                x.For<ICartActions>().Use<CartActions>();
                x.For<IPaymentActions>().Use<PaymentActions>();
                x.For<IParameterReader>().Use<ParameterReader>();
                x.For<IPaymentMethodFactory>().Use<PaymentMethodFactory>();
                x.For<IHasher>().Use<Hash>();
                x.For<IOrderFacade>().Use<Order>();
                x.For<IPaymentManager>().Use<PaymentManager>();
                x.For<IResultParser>().Use<ResultParser>();
                x.For<IVerificationManager>().Use<VerificationManager>();
                x.For<IVerificationFacade>().Use<Verification>();
                x.For<IPayExService>().Use<PayExService>();
                x.For<IUpdateAddressHandler>().Use<UpdateAddressHandler>();
                x.For<IMasterPassShoppingCartFormatter>().Use<MasterPassShoppingCartXmlFormatter>();
            });
        }
开发者ID:Amulius112,项目名称:PayEx.EPi.Commerce.Payment,代码行数:26,代码来源:DependencyResolverModule.cs

示例15: RegisterInMemoryUniform

        internal UniformConfigurator RegisterInMemoryUniform(IContainer container)
        {
            UniformContext uniformContext = new InMemoryContext();
            container.Configure(config => config.For<UniformContext>().Singleton().Use(uniformContext));

            return this;
        }
开发者ID:Ontropix,项目名称:whowhat,代码行数:7,代码来源:UniformConfigurator.cs


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