c# - Injecting class dynamically based on request using Unity -
i using developing mvc4 application using unity. architecture this.
public interface irepositoy<t> { } public class datarepository<t>:irepository { }
basically here t model.
then again
public interface imodel { //property , methods } public class mobile: imodel
all model classes inherit interface.
now in unity using following syntax
registertype<irepository<mobile>, datarepository<mobile>>();
and here problem.
i want "mobile" class dependent on request url. mobile page request "mobile" class injected, if "camera" page requested camera object injected.
i using if-else. looking more sophisticated way make code more maintainable , robust. new unity , di don't know best way.
can please help?
i think you're looking @ wrong way.
all need product controller in case. base class entity product , you'd inherit class in model stuff like mobile, desktop or not. check ef inheritance:
Comments
Post a Comment