I have a library that's meant to be used both on desktop apps and web apps.
This library has a reference to an external data-access component that on desktop should be bound as singleton and on web should be on request scope.
- Desktop project references Core project
- Web project references Core project
- Core project references ExternalComponent
Today I'm forced to do this on the web-client:
Bind<ExternalComponent.IDataAccessComponent>()
.To<ExternalComponent.DataAccessComponent()
.InRequestScope()
.WithConstructorArgument(...);
And on the desktop client, the same but with InSingletonScope()
which forces my web and desktop apps to reference ExternalComponent.dll which is not my intention.
How can I make the binding so I can specify from the client (web or desktop) the scope that I need this external component to be on, without having the client to reference this data-access component?
I'm thinking some method on the Core project that receives the scope that the client needs and set all up, but i can't find something in the Ninject API that let's me do that.
I'm not sure why this is necessary but it is only possible when using the syntax that accepts
System.Type
:The above removes the strong binding semantics.