castle-windsor

Configure windsor interceptor to hook only marked methods

时间秒杀一切 提交于 2020-02-05 05:15:08
问题 Is there possibility to configure Interceptor to hook methods only of special interface, or by base class? Currently I have registered Interceptor that works with scope of connections to one DB. Now I added another scope working with another db and want to add another interceptor, which will hook methods of second scope. It is possible to configure interceptor via xml files, instead of checking target of invocation properties. I've added interceptor via components: <component type="Common.IoC

Castle Windsor resolving a generic interface

主宰稳场 提交于 2020-02-01 07:24:29
问题 I have generic interface with some implementations. interface IBaseInterface<in TObject, out TDetails> { TDetails GetDetails(TObject obj); } abstract class BaseImpl<TObject> : IBaseInterface<TObject, string> { public abstract string GetDetails(TObject obj); } class Impl0 : BaseImpl<decimal> { public override string GetDetails(decimal obj) { return "decimal"; } } class Impl1 : BaseImpl<string> { public override string GetDetails(string obj) { return "string"; } } class Impl2 : BaseImpl<Details

Why not use an IoC container to resolve dependencies for entities/business objects?

旧时模样 提交于 2020-01-26 05:15:21
问题 I understand the concept behind DI, but I'm just learning what different IoC containers can do. It seems that most people advocate using IoC containers to wire up stateless services, but what about using them for stateful objects like entities? Whether it's right or wrong, I normally stuff my entities with behavior, even if that behavior requires an outside class. Example: public class Order : IOrder { private string _ShipAddress; private IShipQuoter _ShipQuoter; public Order(IOrderData

How to get instance of service in Windsor Castle

六眼飞鱼酱① 提交于 2020-01-17 07:24:25
问题 In a multilayer application (ASP MVC: UI project, DAL project) i registered in web.config the components. Now i have this problem: Unit of Work pattern has do be implemented and i need to get the current instance of a particular service. The registration of the services happened in the UI project, but i need to get the current instance of this service in the DAL project. How do i get this reference? In the UI project i already needed a way to get something resolved: container = new

asp.net mvc test project cannot find windsor file

五迷三道 提交于 2020-01-17 02:20:54
问题 Hi there Im using windsor as a DI container, my code is below public static class ContainerBuilder { public static IWindsorContainer Build() { var container = new WindsorContainer("Configuration\\Windsor.config"); // automatically register controllers container.Register(AllTypes .Of<Controller>() .FromAssembly(Assembly.GetExecutingAssembly()) .Configure(c => c.LifeStyle.Transient.Named(c.Implementation.Name.ToLower()))); container.Register( Component.For<IServiceLocator>().Instance(new

Castle Facilities NHibernateIntegration for NHibernate 4.0

痞子三分冷 提交于 2020-01-16 00:50:26
问题 I downloaded the source for NHibernateIntegration from (https://github.com/mahara/Castle.Facilities.NHibernateIntegration) I added reference for Castle.Core (3.3.0.0), Castle.Services.Transaction (3.3.0.0), Castle.Windsor (3.3.0.0), NHibernate (4.0.0.4000) and I built the application to generate the Castle.Facilities.NHibernateIntegration.dll But after the upgrading NHibernateIntegration.dll in my application I am getting the following error, An ISessionFactory component was not mapped for

Windsor registration for generic commands/command handlers

China☆狼群 提交于 2020-01-15 11:24:47
问题 Here's my scenario: public static class DomainCommandProcessor { public static void Dispatch<T>(T command) where T : IDomainCommand { var serviceLocator = ServiceLocator.Current; var handler = serviceLocator.GetInstance<IDomainCommandHandler<T>>(); if (handler != null) handler.Handle(command); } } public class FakeGenericCommand<T1, T2> : IDomainCommand { public FakeGenericCommand(T1 first, T2 second) { First = first; Second = second; } public T1 First { get; private set; } public T2 Second {

Windsor registration for generic commands/command handlers

馋奶兔 提交于 2020-01-15 11:24:01
问题 Here's my scenario: public static class DomainCommandProcessor { public static void Dispatch<T>(T command) where T : IDomainCommand { var serviceLocator = ServiceLocator.Current; var handler = serviceLocator.GetInstance<IDomainCommandHandler<T>>(); if (handler != null) handler.Handle(command); } } public class FakeGenericCommand<T1, T2> : IDomainCommand { public FakeGenericCommand(T1 first, T2 second) { First = first; Second = second; } public T1 First { get; private set; } public T2 Second {

Castle Windsor Cannot Intercept Component Registered For A Class Instance

对着背影说爱祢 提交于 2020-01-15 11:05:51
问题 I have problem intercepting a component registered to a class intance. //this does not get intercepted container.Register(Component.For<IService>().Instance(instanceService) .Interceptors<Interceptor>()); Interceptor works if I register the component without using the class instance //this get intercepted container.Register(Component.For<IService>().ImplementedBy<SampleService>() .Interceptors<Interceptor>()); Is this a bug or by design? Thanks This is unit test code. [Test] public void Test

Castle Windsor Cannot Intercept Component Registered For A Class Instance

淺唱寂寞╮ 提交于 2020-01-15 11:05:17
问题 I have problem intercepting a component registered to a class intance. //this does not get intercepted container.Register(Component.For<IService>().Instance(instanceService) .Interceptors<Interceptor>()); Interceptor works if I register the component without using the class instance //this get intercepted container.Register(Component.For<IService>().ImplementedBy<SampleService>() .Interceptors<Interceptor>()); Is this a bug or by design? Thanks This is unit test code. [Test] public void Test