Skip to content

Instantly share code, notes, and snippets.

@dejanvasic85
Created February 15, 2015 05:46
Show Gist options
  • Save dejanvasic85/53e93c31cc458f84bb31 to your computer and use it in GitHub Desktop.
Save dejanvasic85/53e93c31cc458f84bb31 to your computer and use it in GitHub Desktop.
public static class UnityConfig
{
public static IUnityContainer RegisterComponents()
{
var container = new UnityContainer();
// Register all repository classes automatically
// Register all service classes automatically in the business layer
container.RegisterTypes(
AllClasses.FromAssemblies(new[]
{
Assembly.Load("Neemo"),
Assembly.Load("Neemo.CarParts"),
Assembly.Load("Neemo.CarParts.Repository"),
}),
WithMappings.FromMatchingInterface,
WithName.Default);
// Override a specific auto registration (above) by specifying an override
container.RegisterType<IImageService, IFileImageService>(new InjectionConstructor(HttpContext.Current.Server.MapPath("~/"), typeof(IConfig)))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment