Frage

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

War es hilfreich?

Lösung

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top