-
Notifications
You must be signed in to change notification settings - Fork 33
Description
I'm trying to use the decorator feature with ctor param by using Castle Dynamic Proxy for generating dynamic proxy types as decorators for using them as interceptors. When I Export the dependency by factory under any conditions , it doesn't work. But there's no problem if the dependency does not have any conditions.
` block
.ExportDecorator(decoratorType)
.As(tServiceType)
.WithCtorParam<GenericCastleInterceptor, IInterceptor[]>(i => new IInterceptor[] { i });
block
.ExportFactory<IServiceProvider, GenericCastleInterceptor>(sp =>
{
return new GenericCastleInterceptor(applicationInterceptorsTypes, sp);
})
.As<GenericCastleInterceptor>()
.When.InjectedInto(type =>
{
return true;
})
.When.MeetsCondition((strategy, context) =>
{
return true;
});
`
or
` block
.ExportDecorator(decoratorType)
.As(tServiceType)
.WithCtorParam<GenericCastleInterceptor, IInterceptor[]>(i => new IInterceptor[] { i });
block
.ExportFactory<IServiceProvider, GenericCastleInterceptor>(sp =>
{
return new GenericCastleInterceptor(applicationInterceptorsTypes, sp);
})
.As<GenericCastleInterceptor>()
.When.InjectedInto(decoratorType);
`
The above code snippets do not work whether using InjectedInto
or hacking with MeetsCondition
to make conditions for exporting. But the code snippet below works well.
` block
.ExportDecorator(decoratorType)
.As(tServiceType)
.WithCtorParam<GenericCastleInterceptor, IInterceptor[]>(i => new IInterceptor[] { i });
block
.ExportFactory<IServiceProvider, GenericCastleInterceptor>(sp =>
{
return new GenericCastleInterceptor(applicationInterceptorsTypes, sp);
})
.As<GenericCastleInterceptor>();
`