this is my setup:
public class MyEnums { [Flags] public enum MyGroups { None = 0, Test1 = 1, Test2 = 2 } } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] public sealed class MyAttribute : AuthorizeAttribute { private readonly MyGroups _allowedGroups; public MyAttribute(MyGroups allowedGroups) { _allowedGroups = allowedGroups; } ... } [MyAttribute(MyGroups.Test1 | MyGroups.Test2)] public class MyController : Controller { ... } I specifically do not understand what is happening in the [MyAttribute(MyGroups.Test1 | MyGroups.Test2)] part on the controller side. Am I instantiating multiple attributes (?)"
[MyAttribute(MyGroups.Test1)] [MyAttribute(MyGroups.Test2)] Thanks in advance!
AttributeUsageis an excellent example. In your code it specifies thatMyAttributeis valid on Classes and MethodsMyGroupsenum. in your[MyAttribute(MyGroups.Test1 | MyGroups.Test2)]the value ofallowedGroupswould be 3 (bothMyGroups.Test1andMyGroups.Test2)