Last active
June 3, 2016 09:55
-
-
Save daniiiol/90b63503bfe0665c642f862f3ec2553f to your computer and use it in GitHub Desktop.
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 class UnityConfig | |
{ | |
#region Unity Container | |
private static Lazy<IUnityContainer> container = new Lazy<IUnityContainer>(() => | |
{ | |
var container = new UnityContainer(); | |
RegisterTypes(container); | |
return container; | |
}); | |
/// <summary> | |
/// Gets the configured Unity container. | |
/// </summary> | |
public static IUnityContainer GetConfiguredContainer() | |
{ | |
return container.Value; | |
} | |
#endregion | |
/// <summary>Registers the type mappings with the Unity container.</summary> | |
/// <param name="container">The unity container to configure.</param> | |
/// <remarks>There is no need to register concrete types such as controllers or API controllers (unless you want to | |
/// change the defaults), as Unity allows resolving a concrete type even if it was not previously registered.</remarks> | |
public static void RegisterTypes(IUnityContainer container) | |
{ | |
var rootPath = HostingEnvironment.MapPath("~/"); | |
var basePath = PathInfo.Combine(PathInfo.Create(rootPath), PathInfo.Create(ConfigurationManager.AppSettings["NitroNet.BasePath"])).ToString(); | |
new DefaultUnityModule(basePath).Configure(container); | |
new SitecoreUnityModule().Configure(container); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment