Created
May 28, 2013 07:27
-
-
Save ielcoro/5661058 to your computer and use it in GitHub Desktop.
Unity 3 Mapping Examples
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
public static void Configure(UnityContainer container) | |
{ | |
//Mix explicit mapping with Auto-Registration | |
container.RegisterType<IEntityFrameworkUnitOfWork, UnitOfWork>(new HierarchicalLifetimeManager(), new InjectionConstructor()); | |
//Select only repositories in loaded assemblies | |
container.RegisterTypes(AllClasses.FromLoadedAssemblies() | |
.Where(type => type.BaseType != null && type.BaseType.IsGenericType && | |
type.BaseType.GetGenericTypeDefinition() == typeof(BaseRepository<>)), | |
WithMappings.FromMatchingInterface, | |
WithName.Default); | |
} |
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
public static void Configure(UnityContainer container) | |
{ | |
container.RegisterType<IEntityFrameworkUnitOfWork, UnitOfWork>(new HierarchicalLifetimeManager(), new InjectionConstructor()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment