Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. using ChacoBot.Storage;
  2. using ChacoBot.Storage.Implementations;
  3. using Unity;
  4. using Unity.Resolution;
  5.  
  6. namespace ChacoBot
  7. {
  8. public static class Unity
  9. {
  10. private static UnityContainer _container;
  11.  
  12. public static UnityContainer Container
  13. {
  14. get
  15. {
  16. if(_container == null)
  17. RegisterTypes();
  18. return _container;
  19. }
  20. }
  21.  
  22. public static void RegisterTypes()
  23. {
  24. _container = new UnityContainer();
  25. _container.RegisterType<IDataStorage, InMemoryStorage>();
  26. }
  27.  
  28. public static T Resolve<T>()
  29. {
  30. return (T)Container.Resolve(typeof(T), string.Empty, new CompositeResolverOverride());
  31. }
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement