Eresor

Untitled

Oct 19th, 2019
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. using System.Collections.Generic;
  2.  
  3. class ServiceLocator
  4. {
  5. private Dictionary<Type,object> bindings = new Dictionary<Type,object>();
  6.  
  7. public void Bind<T>(T implementation)
  8. {
  9. bindings[typeof(T)] = implementation;
  10. }
  11.  
  12. public T Resolve<T>()
  13. {
  14. return bindings[typeof(T)];
  15. }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment