使用 StructureMap 3.0.3.116 使用自定义 IRepository<,> 和 SharpRepository 初始化服务,structuremap 仍然无法使用默认约定找到具体类。
public interface IBlogImageRepository : IRepository<BlogImage,int>
{
}
public class BlogImageRepository :
ConfigurationBasedRepository<BlogImage, int>, IBlogImageRepository
{
错误:
没有注册默认实例,并且无法为类型“My.Assembly.Repositories.IBlogImageRepository”自动确定
ObjectFactory.Initialize(x =>
{
x.Scan(scan =>
{
scan.Assembly("S3.Libs");
scan.IncludeNamespace("S3.Libs.Repositories");
scan.IncludeNamespace("S3.Libs.Services");
scan.WithDefaultConventions();
scan.ConnectImplementationsToTypesClosing(typeof (IRepository<,>));
});
x.Scan(scan =>
{
scan.TheCallingAssembly();
scan.WithDefaultConventions();
});
});