I have a lot of implementations that would be good if all their bindings were named dynamically, pe. marking a class with a special attribute with the named instance. Currently, Named method only accepts string as a parameter, not a function like others that could use IContext. Is there a way to do what I'm trying to do currently with Ninject? Thank you.
this.Bind(
ctx =>
{
ctx.FromThisAssembly()
.SelectAllClasses()
.InheritedFrom<IReportGenerationManager>()
.WithAttribute<ReportPeriodicityAttribute>(attr => attr.Value == "Monthly")
.BindToSelf()
.Configure(
syntax =>
syntax
.Named(/* I WANT HERE TO READ THE CLASS ATTRIBUTE TO NAME THE BINDING */)
.WithConstructorArgument(
"dataMartRepository",
ctxArg => ctxArg.Kernel.Get<IDataMartRepository>("Monthly")));
});
I have a lot of implementations that would be good if all their bindings were named dynamically, pe. marking a class with a special attribute with the named instance. Currently, Named method only accepts string as a parameter, not a function like others that could use IContext. Is there a way to do what I'm trying to do currently with Ninject? Thank you.