Created
February 1, 2011 18:08
-
-
Save vquaiato/806289 to your computer and use it in GitHub Desktop.
Exemplo manual IDependencyResolver
This file contains hidden or 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 class MeuDependencyResolver : IDependencyResolver | |
{ | |
private HashSet<object> dependencias; | |
public MeuDependencyResolver() | |
{ | |
this.dependencias.Add(new DummyDependencia1()); | |
this.dependencias.Add(new DummyDependencia2()); | |
this.dependencias.Add(new DummyDependencia2_2()); | |
} | |
public object GetService(Type serviceType) | |
{ | |
return this.dependencias.ToLookup(l => l.GetType())[serviceType].FirstOrDefault(); | |
} | |
public IEnumerable<object> GetServices(Type serviceType) | |
{ | |
return this.dependencias.Where(t => t.GetType() == serviceType).ToList(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Opa!! Dei uma refatorada, o legal é que agora o container pode conter mais de um controller com dependências diferentes.
https://github.com/rodrigobrito/ExemploDependencyResolver