문제

Is there a possibility to use an class/method attribute only when a condtion is met? i.e. a registry in the system of a specific value or an app.config setting would indicate, if this custom attribute should be applied to a class? Thanks

도움이 되었습니까?

해결책

No. You'd need to put that condition into whatever's using the attribute. The attribute is either applied to the member or not, unconditionally (as it's in the file itself).

Of course you can conditionally apply it or not apply it at compilation time, although doing that on the basis of a registry setting or app.config setting would require a bit of trickiness to change the build settings.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top