本文整理汇总了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>());
}
示例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>());
}
示例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());
});
}
示例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;
}
示例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 ) );
}
示例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;
}
示例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;
}
示例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);
}
示例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
});
}
示例10: ApplicationStartup
protected override void ApplicationStartup(IContainer container, IPipelines pipelines)
{
base.ApplicationStartup(container, pipelines);
RavenDbHelper.ConfigureRaven(container);
container.Configure(x => x.SelectConstructor(() => new FakeNancyModule()));
}
示例11: RegisterInMemoryEventStore
internal EventStoreConfigurator RegisterInMemoryEventStore(IContainer container)
{
var eventStore = new InMemoryEventStore(EventStoreSettings.GetDefault());
container.Configure(config => config.For<IEventStore>().Singleton().Use(eventStore));
return this;
}
示例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();
});
}
示例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);
}
示例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>();
});
}
示例15: RegisterInMemoryUniform
internal UniformConfigurator RegisterInMemoryUniform(IContainer container)
{
UniformContext uniformContext = new InMemoryContext();
container.Configure(config => config.For<UniformContext>().Singleton().Use(uniformContext));
return this;
}