C
C
CocaColaBear2015-09-18 14:38:37
.NET
CocaColaBear, 2015-09-18 14:38:37

Redefining Attribute?

Hello! Help put me on the right path :)
There is a huge number of controllers. Some controllers require an attribute to be hooked. For example:

[CustomAttribute("Area")]
public class OneApiController : ApiController
{
....
    [CustomAttribute(Role = "admin,user")]
    public string Method1() { return ""; }
    [CustomAttribute(Role = "user")]
    public string Method2() { return ""; }
    ...
    [CustomAttribute(User = "Ololosh")]
    public string MethodN() { return ""; }
...
}

In general, the point is. What is the topmost attribute, where "Area" is used in any other way in all other attributes. And I would like to ask it somehow initially.
For example, a head-on solution, now:
public class OneApiController : ApiController
{
....
    [CustomAttribute("Area", Role = "admin,user")]
    public string Method1() { return ""; }
    [CustomAttribute("Area", Role = "user")]
    public string Method2() { return ""; }
    ...
    [CustomAttribute("Area", User = "Ololosh")]
    public string MethodN() { return ""; }
...
}

But duplicating in each "Area" attribute is not very pleasant. Is it possible to somehow pass it implicitly to the attribute in advance?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Kovalsky, 2015-09-18
@dmitryKovalskiy

Can't this be done at the controller level? Or do you want to hang 1 attribute globally, and then hang only input parameters for each property?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question