flexible-aspnetcore-authorization icon indicating copy to clipboard operation
flexible-aspnetcore-authorization copied to clipboard

Expand more on Enum Flags?

Open nsmela opened this issue 1 year ago • 0 comments

Hey Jason,

Would it be easier to use bit-shifting to declare the permissions? Or make groups of permissions by adding the View and Manage for the Manage permissions? Or would these be a bad practice?

For example:

[Flags]
public enum Permissions
{
    None = 0,
    ViewCounter = 1<<0,  // 1
    ViewWeather = 1<<1,  // 2
    ViewRoles = 1<<2,  // 4
    ManageRoles = ViewRoles | 1<<3,  //  4 + 8 = 12
}

nsmela avatar Aug 04 '23 20:08 nsmela