本文整理汇总了C#中Castle.AddFacility方法的典型用法代码示例。如果您正苦于以下问题:C# Castle.AddFacility方法的具体用法?C# Castle.AddFacility怎么用?C# Castle.AddFacility使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Castle
的用法示例。
在下文中一共展示了Castle.AddFacility方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Install
/// <summary>
/// Performs the installation in the <see cref="T:Castle.Windsor.IWindsorContainer"/>.
/// </summary>
/// <param name="container">The container.</param>
/// <param name="store">The configuration store.</param>
public void Install(Castle.Windsor.IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
{
container.AddFacility<LoggingFacility>(f =>
f.LogUsing(LoggerImplementation.Log4net)
.WithConfig("D:\\Home\\PersonalDevel\\log4net-Playground.config"));
//change this to something better or even use App config
container.AddFacility<TypedFactoryFacility>();
container.AddFacility<PersistenceFacility>();
}
示例2: Install
public void Install(Castle.Windsor.IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
{
container.AddFacility<AutoTxFacility>();
container.Register(Component.For<INHibernateInstaller>().ImplementedBy<NHibernateInstaller>());//.LifeStyle.Singleton);
var ni = container.Resolve<INHibernateInstaller>();
var t = container.ResolveAll<IInterceptor>();
//container.AddFacility<NHibernateFacility>();
container.AddFacility<NHibernateFacility>(f => f.DefaultLifeStyle = DefaultSessionLifeStyleOption.SessionPerWebRequest);
container.Install(FromAssembly.Containing<PersonRepository>());
}
示例3: Install
public void Install(Castle.Windsor.IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
{
container.Register(
Classes.FromAssemblyInDirectory(new AssemblyFilter(HttpRuntime.BinDirectory, "Application.Web.*"))
.BasedOn<IController>()
.LifestyleTransient(),
Classes.FromAssemblyInDirectory(new AssemblyFilter(HttpRuntime.BinDirectory, "Application.Web.*"))
.BasedOn<IHttpController>()
.LifestyleTransient()
);
container.Register(
Component.For<IQueryableUnitOfWork, UnitOfWork>().ImplementedBy<UnitOfWork>(),
Component.For<IProfileRepository, ProfileRepository>().ImplementedBy<ProfileRepository>(),
Component.For<IAddressRepository, AddressRepository>().ImplementedBy<AddressRepository>(),
Component.For<IAddressTypeRepository, AddressTypeRepository>().ImplementedBy<AddressTypeRepository>(),
Component.For<IPhoneTypeRepository, PhoneTypeRepository>().ImplementedBy<PhoneTypeRepository>(),
Component.For<IPhoneRepository, PhoneRepository>().ImplementedBy<PhoneRepository>(),
Component.For<IProfileAddressRepository, ProfileAddressRepository>().ImplementedBy<ProfileAddressRepository>(),
Component.For<IProfilePhoneRepository, ProfilePhoneRepository>().ImplementedBy<ProfilePhoneRepository>().LifestyleSingleton(),
Component.For<IContactManager>().ImplementedBy<ContactManager>()
);
container.AddFacility<LoggingFacility>(f => f.UseLog4Net());
LoggerFactory.SetCurrent(new TraceSourceLogFactory());
EntityValidatorFactory.SetCurrent(new DataAnnotationsEntityValidatorFactory());
}
示例4: Install
public void Install(Castle.Windsor.IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
{
container.AddFacility(new LoggingFacility(LoggerImplementation.Log4net, "log4net.config"));
container.AddFacility(new StartableFacility());
container.Register(
Component.For<IDomainEventHandlerCatalog, ICommandHandlerCatalog>().ImplementedBy<CastleFasterflectHandlerCatalog>(),
Component.For<ICommandDispatcher>().ImplementedBy<CommandDispatcher>(),
Component.For<IDomainEventDispatcher>().ImplementedBy<DomainEventDispatcher>(),
Component.For<UnitOfWork>().ImplementedBy<UnitOfWork>());
container.Register(
Component.For<AggregateRootFactory>().UsingFactoryMethod(() => new AggregateRootFactory()));
container.Register(
Component.For<IEventsStore>().ImplementedBy<SqlEventsStore>()
.DependsOn(Property.ForKey("configurationFileName").Eq(HostingEnvironment.MapPath("~/NhEventStoreConfiguration.xml"))));
}
示例5: Install
public void Install(Castle.Windsor.IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
{
container
.AddFacility<TransactionFacility>("autoTxFacility")
.AddFacility<NHibernateFacility>("nhibnernateFacility", cfg => cfg.ConfigurationBuilder<FluentConfigurationBuilder>())
.Register(
Component.For<ISurveyRepository>()
.ImplementedBy<NHibernateSurveyRepository>()
.LifeStyle.Transient
)
;
}
示例6: Install
public void Install(Castle.Windsor.IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
{
container.AddFacility<TypedFactoryFacility>();
container.Register(Classes.FromThisAssembly().BasedOn(typeof(IHub)).LifestyleTransient());
var signalRDependencyResolver = new SignalRDependencyResolver(container);
Microsoft.AspNet.SignalR.GlobalHost.DependencyResolver = signalRDependencyResolver;
container.Register(
Component.For<IUserServiceFactory>().AsFactory()
);
}
示例7: Install
public void Install(Castle.Windsor.IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
{
container.Register(
Component.For(typeof(ICacheProvider<>))
.ImplementedBy(typeof(CacheProvider<>))
.LifeStyle.Transient);
container.AddFacility<TypedFactoryFacility>();
container.Register(
Component.For<ICacheDependencyFactory>()
.AsFactory());
}
示例8: Install
public void Install(Castle.Windsor.IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
{
var assem = Assembly.GetExecutingAssembly();
container.Register(Classes.FromAssembly(assem).BasedOn<ApiController>().LifestyleTransient());
container.AddFacility<TypedFactoryFacility>();
container.Register(
Component.For<IUserServiceFactory>().AsFactory(),
Component.For<IUserService>().ImplementedBy<Shared.Membership.Service.UserService>().LifeStyle.PerWebRequest,
Component.For<IDataBaseAccess>().ImplementedBy<DataBaseAccess>().LifeStyle.PerWebRequest,
Component.For<IDataBaseSettings>().ImplementedBy<DataBaseSettings>().LifeStyle.PerWebRequest,
Component.For<ISnapshotsRepository>().ImplementedBy<SnapshotsRepository>().LifeStyle.PerWebRequest,
Component.For<IDomainHandler<SnapshotsGet>>().ImplementedBy<SnapshotsGetHandlerPersistance>().LifeStyle.PerWebRequest
);
}
示例9: Install
public void Install(Castle.Windsor.IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
{
container.Kernel.Resolver.AddSubResolver(new ArrayResolver(container.Kernel, true));
// PerCall setup
container.AddFacility<WcfFacility>()
.Register(
//WCF services
Component.For<IOrderService>()
.ImplementedBy<OrderService>()
.LifeStyle.ApplyLifeStyle(lifestyleApplier),
//CQRSLite stuff
Component.For<OrderCommandHandlers>().LifeStyle.ApplyLifeStyle(lifestyleApplier),
Component.For<IEventPublisher>().ImplementedBy<BusEventPublisher>().LifeStyle.Singleton,
Component.For<IInterProcessBus>().ImplementedBy<InterProcessBus>().LifeStyle.Singleton,
Component.For<ISession>().ImplementedBy<Session>().LifeStyle.ApplyLifeStyle(lifestyleApplier),
Component.For<IEventStore>().ImplementedBy<InMemoryEventStore>().LifeStyle.Singleton,
Component.For<IReadModelRepository>().ImplementedBy<ReadModelRepository>().LifeStyle.Singleton,
Component.For<IBusEventHandler>().ImplementedBy<OrderCreatedEventHandler>()
.Named("OrderCreatedEventHandler").LifeStyle.Singleton,
Component.For<IBusEventHandler>().ImplementedBy<OrderAddressChangedEventHandler>()
.Named("OrderAddressChangedEventHandler").LifeStyle.Singleton,
Component.For<IBusEventHandler>().ImplementedBy<OrderDeletedEventHandler>()
.Named("OrderDeletedEventHandler").LifeStyle.Singleton,
Component.For<IRepository>().UsingFactoryMethod(
kernel =>
{
return
new CacheRepository(
new Repository(kernel.Resolve<IEventStore>(), kernel.Resolve<IEventPublisher>()),
kernel.Resolve<IEventStore>());
})
);
}
示例10: Install
public void Install(Castle.Windsor.IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
{
container.AddFacility<LoggingFacility>(f => f.LogUsing(LoggerImplementation.Log4net).WithAppConfig());
container.AddFacility<TypedFactoryFacility>();
}
示例11: Install
public void Install(Castle.Windsor.IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
{
var kernel = container.Kernel;
kernel.Resolver.AddSubResolver (new CollectionResolver (kernel));
container.AddFacility<TypedFactoryFacility> ();
//Configuration
container.Register (
Component.For<IConfigurationProvider, ISerialConfigurationProvider, IEmonCmsConfiguration> ().ImplementedBy<AppSettingsBasedConfiguration> ()
);
//dbContext
container.Register (Component.For<IHelloHomeDbContext> ().ImplementedBy<HelloHomeDbContext> ().LifestyleBoundTo<IMessageHandler> ());
container.Register (Component.For<HelloHomeDbContext> ().LifestyleTransient().Named("TransientDbContext"));
//Agents
container.Register (Component.For<INodeGatewayAgent> ()
.ImplementedBy<NodeGatewayAgent> ()
.LifestyleSingleton ());
container.Register (Component.For<IEmonCmsAgent> ().ImplementedBy<EmonCmsAgent> ());
//Parsers & encoders
container.Register (Classes.FromAssemblyContaining<IMessageParser> ().BasedOn<IMessageParser> ().WithServiceBase ());
container.Register (
Classes.FromAssemblyContaining<IMessageEncoder> ().BasedOn<IMessageEncoder> ().WithServiceBase (),
Component.For<PinConfigEncoder> ()
);
//EmonCmsUpdater
container.Register (Component.For<IEMonCmsUpdater> ().ImplementedBy<EMonCmsUpdater> ());
//HelloHomeGateway
container.Register (Component.For<HelloHomeGateway> ());
//MessageHandlers
container.Register (
Classes.FromAssemblyContaining<IMessageHandler> ()
.BasedOn (typeof (MessageHandler<>))
.WithServiceSelf ()
.LifestyleTransient (),
Component.For<MessageHandlerComponentSelector> ()
.LifestyleSingleton (),
Component.For<IMessageHandlerFactory> ()
.AsFactory (typeof (MessageHandlerComponentSelector))
);
//Queries & Commands
container.Register (Classes.FromAssemblyContaining<IQuery> ().BasedOn<IQuery> ().WithServiceAllInterfaces ().LifestyleBoundTo<IMessageHandler> ());
container.Register (Classes.FromAssemblyContaining<ICommand> ().BasedOn<ICommand> ().WithServiceAllInterfaces ().LifestyleBoundTo<IMessageHandler> ());
//Logic
container.Register (
Component.For<ITimeProvider> ().ImplementedBy<TimeProvider> ().LifestyleBoundTo<IMessageHandler> (),
Component.For<IRfIdGenerationStrategy> ().ImplementedBy<FindHoleRfIdGenerationStrategy> ().LifestyleBoundTo<IMessageHandler> ()
);
if(_overrides != null)
foreach (var r in _overrides)
container.Register (r.Named (Guid.NewGuid ().ToString ()).IsDefault ());
}
示例12: Install
public void Install(Castle.Windsor.IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
{
container.AddFacility<LoggingFacility>(f => f.UseNLog());
}