0

I used some class from a lib, and I want to define some additional attribute to one class in the lib.

Take an example, we use a library which has a sub class of Web Api ApiController, and it is a seal class which can not be extended, I want to add an AuthenticationFilter attribute to this class and some actions with that class.

Is there any way to implement this? thanks.

Vincent
  • 340
  • 2
  • 11
  • Look here: http://stackoverflow.com/questions/129285/can-attributes-be-added-dynamically-in-c and here: http://stackoverflow.com/questions/14663763/how-to-add-an-attribute-to-a-property-at-runtime – Sebastian Siemens Jun 07 '16 at 07:21
  • Actions where? That API shares the authentication of the system, and You like to add filtering? – ntohl Jun 07 '16 at 07:22
  • Take an example, the library I use as a controller name like OverallController, and has action like get, post,patch, delete. I can not modify this class or extend this class, I want to define a customized AuthorizationFilter class, and want to add AuthorizationFiter Attribute to get action which only need normal access, and filter for post/patch/delete method to request admin access. How can I add these filter to an existing class without any changes to it? Can I define some additional class to define attribute and will be used by that class? – Vincent Jun 10 '16 at 00:20

0 Answers0