c# - Ninject WithConstructorArgument not overriding global binding for type? -


i have general bindings, , 1 of this:

bind<ihasher>().to<sha256hasher>(); 

this works great, there few classes throughout use hasher. there 1 or 2 controllers require type of hasher using hash 3rd parties, such gravatar expect md5 hashes. below:

bind<isomecontroller>().to<somecontroller>().named("somecontroller").withconstructorargument("emailhasher", new md5hasher()); 

then controller looks like:

    public class somecontroller : controller     {         private ihasher emailhasher;          public campaigncontroller(ihasher emailhasher)         {             this.emailhasher = emailhasher;         }     } 

when debugging expect ihasher md5hasher, sha256hasher. expected behaviour , way make use overridden type?

i suppose mvc controller. mvc framework resolve somecontroller not isomecontroller. hence binding not apply ninject use implicit binding somecontroller toself instead.

create binding somecontroller toself instead.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -