Created
February 4, 2016 09:33
-
-
Save TimMurphy/cefa13c4ea05d046128c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public static class DependencyResolver | |
{ | |
Private static IServiceProvider _customServiceProvider; | |
Private static IServiceProvider _defaultServiceProvider; | |
Public static void SetResolver(IServiceProvider) | |
Internal static GetService(Type) | |
( | |
Var service = _currentServiceProvider.GetService(type); | |
If (service != null) | |
{ | |
Return service; | |
} | |
Service = _defaultServiceProvider.GetService(type); | |
If (service != null) | |
{ | |
Return service; | |
} | |
Service = Activator.CreateInstance(type); | |
If (service != null) | |
{ | |
Return service; | |
} | |
Throw new CannotFindService(type); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment