Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lukesmith/359907 to your computer and use it in GitHub Desktop.
Save lukesmith/359907 to your computer and use it in GitHub Desktop.
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