Castle Windsor intercept method call from within the class

后端 未结 5 1789
予麋鹿
予麋鹿 2020-12-17 05:47

We have components registrations in Castle Windsor container like so

void RegisterComponent() {
    var component = Compon         


        
5条回答
  •  庸人自扰
    2020-12-17 06:26

    @NikolayKondratyev I've looked into https://github.com/castleproject/Windsor/blob/master/src/Castle.Windsor/Windsor/Proxy/DefaultProxyFactory.cs#L110 and I've done the registration the easy way: container.Register(Classes.FromThisAssembly().BasedOn(typeof(IRepositoryBase<,>)) .WithServiceAllInterfaces().WithServiceSelf() .LifestyleTransient());

    Note .WithServiceSelf() call, this actually switches class-based proxying

提交回复
热议问题