-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Type Activator For Decorator, Does Not Invoke Dependency's Factory if It Has Conditions #279
Comments
When you use just the MeetsCondition method is the method being called to test if it meets the condition? If so can you look at the static injection information and look to see what types it's being injected into? I'm not able to replicate the problem but I also don't have the same sets of dependencies so I'm not sure what's going on. |
Hi @ipjohnson I think the problem is |
Decorated classes never know they are being decorated and the information isn't passed onto the conditional logic. The examples you gave aren't injecting into anything so the injected into information is going to be blank. |
Hi @ipjohnson Sounds reasonable for the layers of abstraction in the operational code. But is it ok for injecting contexts too? Practically, the service is going to be decorated will be injected into the decorator. By having this point of view, behaving decoration is some like injection, Therefore injecting interfaces should work there too. |
I understand where you're coming from but ultimately it's not how it was implemented. Currently when a dependency is located we find a registration that matches and then decorate it. So the conditional logic for selecting a dependency is run then decorators are applied. |
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 });
`
or
` block
.ExportDecorator(decoratorType)
.As(tServiceType)
.WithCtorParam<GenericCastleInterceptor, IInterceptor[]>(i => new IInterceptor[] { i });
`
The above code snippets do not work whether using
InjectedInto
or hacking withMeetsCondition
to make conditions for exporting. But the code snippet below works well.` block
.ExportDecorator(decoratorType)
.As(tServiceType)
.WithCtorParam<GenericCastleInterceptor, IInterceptor[]>(i => new IInterceptor[] { i });
`
The text was updated successfully, but these errors were encountered: