私はコンストラクタを持っています
[ReadFromFile(@"C:\SampleData\login.json")]
public AccountController(IReadRepository<LoginMockDataModel> repository, string filePath) : base(repository)
{
}
この属性には、プロパティ「FilePath」が含まれています。
public string FilePath {get;set;}
上記の場合、「C:\SampleData\login.json」になる「FilePath」の値を取得したいと思います。
Ninject の IContext を使用して値を取得することは可能ですか?
アイデアは、プロパティの値を取得し、次のようにバインディングで使用することです。
// 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);
ここで、CheckAttributePath はデリゲートになります。
private object CheckAttributePath(IContext arg)
{
throw new NotImplementedException();
}
属性の値を取得する方法がわかりません。