【发布时间】:2021-10-28 21:53:32
【问题描述】:
我正在使用选项服务绑定分层configuration 数据。
但假设我有这样的课程:
public class PersonOptions
{
public string Name { get; set; }
public int Age { get; set; }
public bool Foo { // <--- I want binder to ignore this
get {
// ... do stuff
}
}
public bool IgnoreMe => // <--- I want binder to ignore this
throw new Exception();
}
因为Foo属性是public,绑定器运行它并触发一些抛出异常的代码。
我的设计要求它是public,我不想把它改成一个方法。
我可以使用某些属性或覆盖来告诉活页夹忽略该属性吗?
【问题讨论】:
-
the binder runs it and triggers some code that throws exceptions也请分享错误信息。
标签: c# asp.net-core configuration appsettings asp.net-core-5.0