Skip to content

Instantly share code, notes, and snippets.

@TimMurphy
Created February 4, 2016 09:33
Show Gist options
  • Save TimMurphy/cefa13c4ea05d046128c to your computer and use it in GitHub Desktop.
Save TimMurphy/cefa13c4ea05d046128c to your computer and use it in GitHub Desktop.
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