Reputation: 599
I want to facade or proxy a library's implemented attribute. for example the property mapping attributes.
I want to control which of the libraries attributes to be used in project. some kind of a DI or Module control. Is there an easy way to achieve it without using reflection?
something to transfer these two types of attributes into one:
[MapsFromAndToProperty(typeof(fooClass), nameof(fooClass.PropertyName))]
and
[AdaptMember(name)]
into
[MyAttributeToControlWhichOneToUse(typeof(fooClass), nameof(fooClass.PropertyName))]
And Thank you for your attention. Any help would be appreciated.
Upvotes: 0
Views: 171
Reputation: 5791
As noted in the comments, it is not possible to alter attributes in the general case. This is simply because attributes are effectively part of the assembly metadata and doing what you want means to change that assembly metadata.
There are two ways how this could potentially work, though:
MyAttributeToControlWhichOneToUse
attribute into the required attributes at compile-time. This solution is independent of the way how the attributs are read, but requires changes to the build infrastructure.Upvotes: 1