Adding Dependency Injection to your ASP.NET MVC Twilio app using MEF
Blog post from Twilio
Mef (Managed Extensibility Framework) is being used in this ASP.NET MVC 4 application to add dependency injection for the TwilioRestClient class. The MefMvcConfig class registers Mef in the Application_Start method, and the MefMvcControllerFactory class is used to scan the CompositionContainer when resolving Controller types. The HomeController class is decorated with the [Export] attribute, which enables Mef to export its instances for injection. The Register action in the AccountController uses ServiceLocator to resolve the dependency on TwilioRestClient, allowing it to be injected and activated by Mef. A custom adapter class, TwilioRestClientMefAdapter, is created to wrap the TwilioRestClient class and provide a parameterless constructor, which is required for Mef's CompositionContainer to work. The ServiceLocator currently instance property is used to get an instance of the TwilioRestClient from the CompositionContainer.
No tracked trend matches for this post yet.
Use this post, company, and trend context to find content marketing opportunities, perform competitive analysis, or address product feature gaps via the Plushcap MCP server or the Plushcap API.