What is an alternative to attributes?

Attributes help us use class-specific values ​​instead of instances, and they help us carry some values ​​without a strong connection with our classes. But I found some attribute restrictions. We cannot change these values ​​at runtime. Therefore, I am looking for a way to use a similar concept for attributes, since we have seen many examples of configuration classes using free apis instead of attributes. Do you know such a ready-made library? What is an alternative to using the concept of attributes to prevent attribute restrictions?

+5
source share
3 answers

Actually, in some cases you can configure attributes at runtime - for example, through TypeDescriptor- but this only affects the use of the ComponentModel, and not the use of reflection. You can also write an attribute to do things like resx search for i18n targets.

But other options:

  • possibly a static property, possibly after a naming convention
  • a separate object model that talks about types is a metamodel, so to speak
  • configuration file or similar

Any work will work; which best depends on what you mean.

+3
source

A good attribute replacement in the plug-in architecture may be to use smart naming conventions.

0
source

, - , ? , , .

?

0
source

All Articles