本文整理汇总了C#中IWindsorContainer.AddFacility方法的典型用法代码示例。如果您正苦于以下问题:C# IWindsorContainer.AddFacility方法的具体用法?C# IWindsorContainer.AddFacility怎么用?C# IWindsorContainer.AddFacility使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IWindsorContainer
的用法示例。
在下文中一共展示了IWindsorContainer.AddFacility方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Install
public void Install(IWindsorContainer container, IConfigurationStore store)
{
container.AddFacility<TypedFactoryFacility>();
container.AddFacility<LoggingFacility>(
facility => facility.UseNLog().LogUsing(LoggerImplementation.NLog).WithConfig(NlogConfigPath));
container.Register(
Component.For<IInterceptor>().ImplementedBy<ExceptionInterceptor>(),
Component.For<ICommandFactory>().AsFactory(),
Component.For<IQueryFactory>().AsFactory(),
Classes.FromThisAssembly().BasedOn<ICommand>().WithServiceSelf().LifestylePerWebRequest(),
Classes.FromThisAssembly().BasedOn<IQuery>().WithServiceSelf().LifestylePerWebRequest(),
Component.For<IPayrollDetailsHelper>()
.ImplementedBy<PayrollDetailsHelper>()
.DependsOn(Dependency.OnValue("benefitsDeduction", Convert.ToInt32(GetConfigValue("benefitsDeduction"))))
.DependsOn(Dependency.OnValue("dependentDeductions", Convert.ToInt32(GetConfigValue("dependentDeductions"))))
.DependsOn(Dependency.OnValue("savingsPercentage", Convert.ToInt32(GetConfigValue("SavingsPercentage"))))
.LifestylePerWebRequest(),
Component.For<IDapperHub>()
.ImplementedBy<DapperHub>()
.DependsOn(Dependency.OnValue("databaseConnection", GetConnectionString()))
.LifestylePerWebRequest(),
Classes.FromThisAssembly().BasedOn<ApiController>().LifestyleTransient().Configure(registration => registration.Interceptors<ExceptionInterceptor>()));
}
示例2: AddResolversAndFacilities
private static void AddResolversAndFacilities(IWindsorContainer container)
{
container.Kernel.Resolver.AddSubResolver(new CachingSessionResolver());
container.Kernel.Resolver.AddSubResolver(new ArrayResolver(container.Kernel));
container.AddFacility<TypedFactoryFacility>();
container.AddFacility<StartableFacility>();
}
示例3: Start
private void Start()
{
container = new WindsorContainer();
container.AddFacility<LoggingFacility>(f => f.UseNLog());
container
.AddFacility<AutoTxFacility>()
.Register(
Component.For<IConfigurationPersister>().ImplementedBy<FileConfigurationPersister>(),
Component.For<INHibernateInstaller>().ImplementedBy<NHibInstaller>().LifeStyle.Singleton,
Component.For<Logger>().LifeStyle.Singleton)
.AddFacility<NHibernateFacility>();
using (var scope = new ResolveScope<Logger>(container))
{
using (var up = new ResolveScope<Configuration>(container))
{
new SchemaUpdate(up.Service).Execute(false, true);
}
Console.WriteLine("Current log contents:");
Console.WriteLine("[utc date] - [text]");
Console.WriteLine("-------------------");
scope.Service.ReadLog(Console.WriteLine); // read everything from saved log
scope.Service.WriteToLog(string.Format("{0} - Started", DateTime.UtcNow)); // write simple line to log
}
}
示例4: Install
public void Install(IWindsorContainer container, IConfigurationStore store)
{
container.AddFacility<SqlServerPersistenceFacility>();
container.AddFacility<DomainServicesFacility>();
container.AddFacility<ApplicationServicesFacility>();
container.Register(
Classes.FromThisAssembly()
.BasedOn(typeof (IBootstrapper))
.WithServiceBase()
.LifestyleSingleton());
// for bootstrappers
container.Register(
Component.For<WindsorControllerFactory>().ImplementedBy<WindsorControllerFactory>().LifestyleSingleton(),
Component.For<WindsorValidatorFactory>().ImplementedBy<WindsorValidatorFactory>().LifestyleSingleton());
// register all Fluent Validators
container.Register(
Classes.FromThisAssembly()
.BasedOn(typeof(IValidator<>))
.WithServiceBase()
.LifestyleTransient());
// register all controllers
container.Register(Classes.FromThisAssembly()
.BasedOn<IController>()
.LifestyleTransient());
}
示例5: BuildContainer
public static void BuildContainer()
{
BuilderSetup.SetDefaultPropertyNamer(new PersistableEntityPropertyNamer(new ReflectionUtil()));
_container = new WindsorContainer();
_container = new WindsorContainer();
_container.Kernel.Resolver.AddSubResolver(new CollectionResolver(_container.Kernel));
_container.AddFacility<ConfigurationFacility>();
var config = _container.Resolve<IEnvironmentConfiguration>();
var possiblyInjectedProjectFlavour = Process.GetCurrentProcess().GetProjectFlavour() ?? ProjectFlavour.Application;
EntityFrameworkDataProviderFacility.ConnectionStringProvider =
() => config.ConnectionString(possiblyInjectedProjectFlavour);
EntityFrameworkDataProviderFacility.WithDatabaseInitialiser<AlwaysDropAndRecreateDatabaseStrategyInitialiser>();
_container.AddFacility<EntityFrameworkDataProviderFacility>();
SecurityInstaller.SecurityHelperType = config.SecurityHelperType(possiblyInjectedProjectFlavour);
_container.Install(FromAssembly.This());
_container.Register(Component.For<IWindsorContainer>().Instance(_container));
}
示例6: Init
public void Init()
{
container = new WindsorContainer();
container.AddFacility("1", new MyInterceptorGreedyFacility());
container.AddFacility("2", new MyInterceptorGreedyFacility());
container.AddFacility("3", new MyInterceptorGreedyFacility());
}
示例7: ExplainFacilitiesToWindsor
public static void ExplainFacilitiesToWindsor(IWindsorContainer container)
{
container.AddFacility<TypedFactoryFacility>();
container.AddFacility<LoggingFacility>(f => f.UseLog4Net().WithConfig("log4net.config"));
container.Register(Component.For<ILazyComponentLoader>()
.ImplementedBy<LazyOfTComponentLoader>());
}
示例8: ConfigureFacilities
public IWindsorContainer ConfigureFacilities(IWindsorContainer container)
{
var facility = new LoggingFacility(LoggerImplementation.Console);
container.AddFacility<FactorySupportFacility>();
container.AddFacility("logging", facility);
return container;
}
示例9: BootstrapContainer
private void BootstrapContainer()
{
logger.Debug("Installing Winsdor Castle.");
Container = new WindsorContainer();
Container.AddFacility<LoggingFacility>(f => f.UseNLog("NLog.config"));
Container.AddFacility<TypedFactoryFacility>();
Container.Register(Component.For<IContainerAccessor>().Instance(this));
Container.Install(FromAssembly.Containing<CollectorApiInstaller>());
}
示例10: Install
public void Install(IWindsorContainer container, IConfigurationStore store)
{
container.AddFacility<TypedFactoryFacility>();
container.AddFacility<FactorySupportFacility>();
container.Register(
AllTypes.FromAssemblyContaining(typeof (CreateCustomerCommandHandler))
.Where(x => x.GetInterface(typeof (Consumes<>.All).Name) != null));
}
示例11: Install
public void Install(IWindsorContainer container, IConfigurationStore store)
{
container.Kernel.Resolver.AddSubResolver(new ArrayResolver(container.Kernel));
container.AddFacility(new StartableFacility());
container.AddFacility<LoggingFacility>(f => f.UseNLog().WithConfig(logFileName ?? "nlog.config"));
container.AddFacility<TypedFactoryFacility>();
container.Register(
Component.For<IFileSystem>().ImplementedBy<FileSystem>());
}
示例12: Install
public void Install(IWindsorContainer container, IConfigurationStore store)
{
container.Register(Component.For<IWindsorContainer>().Instance(container));
container.AddFacility<MassTransitFacility>(f => f.ReceiveFromUri = Keys.MassTransitReceiveFrom);
container.AddFacility<EventStoreFacility>(f =>
{
f.ConnectionString = Keys.EventStoreKeyName;
f.SqlDialect = new PostgreSqlDialect();
});
}
示例13: SetupWindsor
private void SetupWindsor()
{
container = new WindsorContainer(new XmlInterpreter());
var configBuilder = new NHConfigBuilder(Server.MapPath("/"));
container.AddFacility("nhibernate", new NHibernateFacility(configBuilder));
container.AddFacility<TransactionFacility>();
container.AddComponent<TransactionalService>();
container.AddComponent<HomeController>("home");
new SchemaExport(configBuilder.GetConfiguration(null)).Execute(false, true, false);
ControllerBuilder.Current.SetControllerFactory(new WindsorControllerFactory(container));
}
示例14: AddComponentsTo
public static void AddComponentsTo(IWindsorContainer container, Type transactionManagerType)
{
ParameterCheck.ParameterRequired(container, "container");
if (!container.Kernel.HasComponent("LogInterceptor")) {
Core.CastleWindsor.ComponentRegistrar.AddComponentsTo(container);
Data.CastleWindsor.ComponentRegistrar.AddComponentsTo(container, transactionManagerType);
container.AddFacility("LogFacility", new LogFacility());
container.AddFacility("ExceptionHandlerFacility", new ExceptionHandlerFacility());
container.AddFacility("TransactionFacility", new TransactionFacility());
container.AddFacility("UnitOfWorkFacility", new UnitOfWorkFacility());
}
}
示例15: ApplicationContainer
public ApplicationContainer()
{
container = new WindsorContainer();
container.AddFacility<TypedFactoryFacility>();
container.AddFacility<LoggingFacility>(f => f.LogUsing(LoggerImplementation.Log4net).WithConfig("log4net.xml"));
container.Kernel.Resolver.AddSubResolver(new CollectionResolver(container.Kernel));
container.Register(Component.For<LogInterceptor>());
container.Install(new RepositoryInstaller());
container.Install(new PresentationInstaller());
container.Install(new ApplicationInstaller());
}