Nancy/TinyIoC multiple concrete classes for single interface -


we have 2 auth methods different modules – userauthmodule , serviceauthmodule. we’ve created 2 base classes modules derive from. we’ve interfaced authproviders iauthprovider. have dependency in constructors should correct authprovider injected. however, can’t find way tell nancy/tinyioc concrete class use. here pseudo-code:

abstract class userauthmodule : nancymodule {   public userauthmodule(iauthprovider authprovider) // should userauthprovider concrete class }  abstract class serviceauthmodule : nancymodule {   public serviceauthmodule(iauthprovider authprovider) // should serviceauthprovider concrete class } 

here's example of 1 of concrete module's class declaration:

public class accountmodule : userauthmodule 

we stuck: how register 2 concrete classes iauthprovider interface? name them, can’t figure out how nancy knows class inject when constructor injection.

inside our bootstrapper have:

container.register<iauthprovider, userauthprovider>(“userauth”); container.register<iauthprovider, serviceauthprovider>(“serviceauth”); 

we resolve type container, there's not container access within nancy module.

is creating unique interface each based off of iauthprovider out of question?

interface iuserauthprovider : iauthprovider { } interface iserviceauthprovider : iauthprovider { } 

and register:

container.register<iuserauthprovider, userauthprovider>(); container.register<iserviceauthprovider, serviceauthprovider>(); 

and modify constructors:

public userauthmodule(iuserauthprovider authprovider) public serviceauthmodule(iserviceauthprovider authprovider) 

Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -