Guest User

Untitled

a guest
Apr 19th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. ILog logger_a = LogManager.GetLogger("A");
  2. ILog logger_b = LogManager.GetLogger("B");
  3. ILog logger_c = LogManager.GetLogger("C");
  4.  
  5. // During application initialization
  6. IUnityContainer myContainer = new UnityContainer();
  7. LoggingService concreteLoggingService = new LoggingService( "logID" );
  8. myContainer.RegisterInstance<ILoggingService>( concreteLoggingService );
  9.  
  10. // This would be injected, so you wouldn't see this, but it's here for consistency
  11. ILoggingService loggingService = myContainer.Resolve<ILoggingService>();
  12. loggingService.LogMessage( "message" );
  13.  
  14. // During application initialization
  15. ServiceLocator.Register<ILoggingService>( new LoggingService( "logID" ) );
  16.  
  17. // Retrieved as needed
  18. ILoggingService loggingServce = LoggingServiceLocator.Locate<ILoggingService>();
  19. loggingService.LogMessage( "message" );
Add Comment
Please, Sign In to add comment