I have just updated to the latest structuremap dll and now my site no longer works at runtime due to deprecated methods in structuremap so I am trying to update my bootstrapper code.
In my bootstrapper class I have rewritten it to:
public class Bootstrapper
{
public static void ConfigureStructureMap()
{
ObjectFactory.Initialize(InitializeStructureMap);
}
private static void InitializeStructureMap(IInitializationExpression x)
{
x.AddRegistry(new DatabaseServiceRegistry());
x.For<IArticleService>().Use<ArticleService>();
x.For<IArticleRepository>().Use<SqlArticleRepository>();
}
}
I have added the registry line as I am using Linq to SQL which is in a seperate project.
This is the code that worked in the older version of StructureMap:
public class DatabaseServiceRegistry : Registry
{
public override void ConfigureStructureMap()
{
ForRequestedType<Database>()
.TheDefaultIs(() => new Database(Settings.Default.server))
.CacheBy(InstanceScope.Hybrid);
}
I think I need to rewrite it to something like this?
public void ConfigureStructureMap()
{
ObjectFactory.Configure(x =>
{
For<Database>().Use(new Database(Settings.Default.server));
});
}
This compiles but then I get a runtime error of:
StructureMap Exception Code: 202 No Default Instance defined for PluginFamily MyProject.Data.SqlRepository.Database
What am I doing wrong? I am finding it hard to find documentation that relates to the latest syntax and not referencing deprecated methods :(