Вопрос

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