2
我想知道如何告訴ninject將範圍設置爲與特定基本類型的所有綁定。我想下面的接近,但它不工作:在Ninject中,如何設置具有特定基接口的所有綁定到單身人士
var scanner = new AssemblyScanner();
scanner.FromCallingAssembly();
scanner.BindWith<DefaultBindingGenerator>();
kernel.Scan(scanner);
//maps.Count is always 0 :-(
var maps = kernel.GetBindings(typeof(IMapper<,>));
foreach (var map in maps)
{
map.ScopeCallback = StandardScopeCallbacks.Singleton;
}
一個對象我想成爲單身:
public interface ILoanApplicationModelToViewMapper : IMapper<LoanApplication, LoanApplicationViewModel>
{
}
public class LoanApplicationModelToViewMapper : Mapper<LoanApplication, LoanApplicationViewModel>, ILoanApplicationModelToViewMapper
{
}