Created
June 9, 2015 19:39
-
-
Save davidbreyer/498cc8d427cdfb855f36 to your computer and use it in GitHub Desktop.
Basic Unity Container running Log4net extensions.
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
| using System; | |
| using Microsoft.Practices.Unity; | |
| using UnityLog4NetExtension.Log4Net; | |
| public static class UnityConfig | |
| { | |
| static IUnityContainer GetContainer() | |
| { | |
| var newContainer = new UnityContainer() | |
| .AddNewExtension<LogCreation>() //Custom extension that executes logger setup | |
| .AddNewExtension<Log4NetExtension>(); | |
| return newContainer; | |
| } | |
| public static IUnityContainer GetConfiguredContainer() | |
| { | |
| return container.Value; | |
| } | |
| static Lazy<IUnityContainer> container { get; set; } | |
| public static void RegisterComponents() | |
| { | |
| container = new Lazy<IUnityContainer>(GetContainer); | |
| // register all your components with the container here | |
| // it is NOT necessary to register your controllers | |
| // e.g. container.Value.RegisterType<ITestService, TestService>(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment