I have a constructor
[ReadFromFile(@"C:\SampleData\login.json")]
public AccountController(IReadRepository<LoginMockDataModel> repository, string filePath) : base(repository)
{
}
The attribute contains a property "FilePath".
public string FilePath {get;set;}
I would like to retrieve the value of "FilePath" which would be "C:\SampleData\login.json" in the above case.
Is it possible to retrieve the value using Ninject's IContext?
The idea is to retrieve the property's value and then use it in the binding as follows:
// FileReadRepo contains a constructor with the argument "filePath"
// which will need a string passed to it which I am trying to retrieve
// from the Attribute above
Bind(typeof(IReadRepository<>)).To(typeof(FileReadRepo<>))
.WhenMemberHas<ReadFromFileAttribute>()
.WithConstructorArgument("filePath", CheckAttributePath);
where CheckAttributePath would be the delegate:
private object CheckAttributePath(IContext arg)
{
throw new NotImplementedException();
}
I'm not sure how to obtain the attribute's value.