![]() |
|
[C#] [Dependency Injection] Registering multiple generic interfaces. - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [C#] [Dependency Injection] Registering multiple generic interfaces. (/showthread.php?tid=5662621) |
[Dependency Injection] Registering multiple generic interfaces. - severos - Jul 5, 2017 Hi there guys, I've been trying to solve this for the past 2 hours without any luck of even finding hints on where, how, or what to look for. Lets say I have 2 interfaces, a public one will be exposed to those using my library, and internal one exposed to my code allowing extra functionality, and a class that implements them: PHP Code Now, I want to register those 2 interfaces for DI, but I want them to have the same object, so I did this: PHP Code Anyone got idea how to solve this?? or even pointers on what to look for?? * - HFDone - Jul 5, 2017 check https://stackoverflow.com/a/24454423 or https://stackoverflow.com/a/14402629 * - severos - Jul 5, 2017 (Jul 5, 2017 09:13 AM)HFDone Wrote: check https://stackoverflow.com/a/24454423 or https://stackoverflow.com/a/14402629 Forgot to mention, I'm using the Microsoft DI container, due to some limitations I'm not allowed to change it. Also, I've already done the part of using same object but for a non generic type, no idea why it's not working this time... Side question: any idea how to consume services during MVC setup? Spoiler (Click to View) Problem solved by changing the approach, closing this thread now. |