Jan 10, 2011 at 12:33 AM
Edited Jan 10, 2011 at 12:35 AM
|
Hello,
I am trying get a CaliburnApplication (Ayende's Alexandria) run using structuremap as the IoC container. Here is the code for the App (which inherits from CaliburnApplication)
private StructureMap.IContainer container;
protected override IServiceLocator CreateContainer()
{
container = new StructureMap.Container(x =>
{
x.AddRegistry(new ClientRegistry());
x.Scan(scan =>
{
scan.TheCallingAssembly();
scan.IncludeNamespaceContainingType<ApplicationModel>();
scan.AssemblyContainingType<MyBooksResponseConsumer>();
scan.ConnectImplementationsToTypesClosing(typeof(Consumes<>.All));
scan.WithDefaultConventions();
});
x.For<ApplicationModel>()
.Singleton();
});
container.AssertConfigurationIsValid();
return new StructureMap.ServiceLocatorAdapter.StructureMapServiceLocator(container);
}
protected override void Register(IEnumerable<Caliburn.Core.IoC.IComponentRegistration> registrations)
{
container.Configure(c =>
{
foreach (var item in registrations)
{
c.For<Caliburn.Core.IoC.IComponentRegistration>().Use(item);
}
});
}
protected override object CreateRootModel()
{
return Container.GetInstance<ApplicationModel>();
}
protected override void BeforeConfiguration()
{
base.BeforeConfiguration();
new EnvironmentVerifier().Verify();
}
}
When the project runs I get an exception :
StructureMap Exception Code: 202No Default Instance defined for PluginFamily Caliburn.Core.IAssemblySource, Caliburn.Core, Version=2.0.0.39524, Culture=neutral, PublicKeyToken=8e5891231f2ed21f
I am not entirely sure if my implementation of the override void Register method makes sense. Previously I was getting
Cannot configure Caliburn. Override Register or provide an IServiceLocator that also implements IRegistry.
I am new to structuremap so I might not be setting it up right for use with caliburn. Please advice. Could someone explain the what typically goes in the Register override?
Thanks in advance.
|