Created
January 6, 2018 23:44
-
-
Save aramkoukia/6316d53aaee1110bbfc4aca55b59d697 to your computer and use it in GitHub Desktop.
Unity Config for Interception
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
| /// <summary> | |
| /// Specifies the Unity configuration for the main container. | |
| /// </summary> | |
| public static class UnityConfig | |
| { | |
| private static Lazy<IUnityContainer> container = | |
| new Lazy<IUnityContainer>(() => | |
| { | |
| var container = new UnityContainer(); | |
| RegisterTypes(container); | |
| container.AddNewExtension<Interception>() | |
| .Configure<Interception>() | |
| .SetDefaultInterceptorFor<IUserRepository>(new TransparentProxyInterceptor()); | |
| return container; | |
| }); | |
| /// <summary> | |
| /// Configured Unity Container. | |
| /// </summary> | |
| public static IUnityContainer Container => container.Value; | |
| public static void RegisterTypes(IUnityContainer container) | |
| { | |
| container.RegisterType<IUserRepository, UserRepository>(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment