I have a basic working knowledge of Castle Windsor, but I cannot figure out the DI equivalent of the below code ...
private static DbModel BuildModel()
{
var builder = new ModelBuilder();
var types = Assembly.GetExecutingAssembly().GetTypes();
foreach (var type in types)
{
if (type.Name.EndsWith("Configuration"))
{
var entityConfiguration = Activator.CreateInstance(type);
var xx = entityConfiguration as StructuralTypeConfiguration;
builder.Configurations.Add(xx);
}
}
var model = builder.CreateModel();
return model;
}
This is intended to automatically load all the Configuration classes in a EF4 code first scenario.
Ideally I want it to pick up all classes in my assembly based on StructuralTypeConfiguration
.
Am I barking up the wrong tree trying to use DI for this? If so, is there a better way of doing this than getting type names ending with "Configuration"?