mvc.net と StructureMap を使用して、すべてのリポジトリとサービスをスキャンして登録しています。次に、Singleton で登録してキャッシュしたいと思います。どのようにできるのか?
IContainer container = new Container(x => {
// Register Repositories and Services
x.Scan(y => {
y.AssemblyContainingType<SomeRepository>();
y.AssemblyContainingType<SomeService>();
y.IncludeNamespaceContainingType<SomeRepository>();
y.IncludeNamespaceContainingType<SomeService>();
});
// Register Controllers
x.Scan(y => {
y.TheCallingAssembly();
y.AddAllTypesOf<IController>().NameBy(type => type.Name.Replace("Controller", ""));
});
});