Created
April 8, 2010 08:35
-
-
Save lukesmith/359907 to your computer and use it in GitHub Desktop.
This file contains 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 System.Linq; | |
namespace BookUpon.Tests | |
{ | |
public static class IMappedEngineConfigurationBuilderExtensions | |
{ | |
public static void ScanAssembly<T>(this IMappedEngineConfigurationBuilder builder) | |
{ | |
var maps = typeof(T).Assembly.GetTypes().Where(x => typeof(IAutoPocoMap<>).IsAssignableFrom(x) && !x.IsAbstract); | |
foreach (var map in maps) | |
{ | |
var t = map.GetGenericArguments()[0]; | |
var genericType = typeof(IAutoPocoMap<>).MakeGenericType(t); | |
builder.Register(Activator.CreateInstance(genericType) as IAutoPocoMap<T>); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment