Мои текущие общие привязки: модуль Ninject
public class GeneralBindings : NinjectModule
{
public override void Load()
{
// Requires Ninject.Extensions.Conventions
// This binds all interfaces to concretes of the same name eg IClass -> Class.
Kernel.Bind(x => x.FromAssembliesMatching("Company.Project.Scm*")
.SelectAllClasses()
.Excluding(typeof(AffectedCables),
typeof(ApplicationConfigurations),
typeof(ApplicationErrors),
typeof(ApplicationLogEvents),
typeof(AppUsers),
typeof(AppUsersContract),
typeof(Areas)
// etc..
)
.BindAllInterfaces());
затем
Bind<IAffectedCables>().To<AffectedCables>()
.InSingletonScope()
.WithConstructorArgument("url", @"api/AffectedCables");
Bind<IApplicationErrors>().To<ApplicationErrors>()
.InSingletonScope()
.WithConstructorArgument("url", @"api/AppErrors");
Bind<IApplicationConfigurations>().To<ApplicationConfigurations>()
.InSingletonScope()
.WithConstructorArgument("url", @"api/AppConfigurations");
Bind<IApplicationLogEvents>().To<ApplicationLogEvents>()
.InSingletonScope()
.WithConstructorArgument("url", @"api/AppEventLogs");
Bind<IAppUsers>().To<AppUsers>()
.InSingletonScope()
.WithConstructorArgument("url", @"api/AppUsers");
Bind<IAppUsersContract>().To<AppUsersContract>()
.InSingletonScope()
.WithConstructorArgument("url", @"api/AppUserContract");
Bind<IAreas>().To<Areas>()
.InSingletonScope()
.WithConstructorArgument("url", @"api/Areas");
// Etc...
...
Кто-нибудь может подсказать, как сделать это лучше? Я уверен, что кто-то может создать одну строку кода, которая сохранит копию и вставку, которые я должен выполнить в данный момент.