Using partial classes for InfiniteEnumFlag #15
michaelswells
started this conversation in
Ideas
Replies: 1 comment
-
|
Hi @michaelswells, var x = Features.F1 | Features.F3;
x.Dump(); // contains both F1 and F3
public partial class Features : InfiniteEnum<Features>
{
public static readonly Flag<Features> None = new(-1);
public static readonly Flag<Features> F1 = new(0);
}
public partial class Features : InfiniteEnum<Features>
{
public static readonly Flag<Features> F2 = new(1);
public static readonly Flag<Features> F3 = new(2);
}
No, you have full control over the enum creation but since the time complexity for generating UniqueIds is O(n), I would suggest trying to keep the bit length as small as possible. In other words, don't jump from 100 to 1000 to 10000 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
First of all, I really like this library as I am moving away from Roles base permissions in favor of @jasontaylordev's flexible authorization project and assign page access permissions (read/write) and page control permissions as needed. Currently I have over 100 permissions in my application. :).
I like to use partial classes to organize sets of objects that are part of the same class but are specific to an area. I was trying to use InfiniteEnumFlags with partial class, since I have sets of permissions for each page, e.g.,
in file Features.cs
in file Features.page01.cs
in file Features.page02.cs
but it does not work, I think InfiniteEnumFlags does not recognize the partial. Is there something I am missing or is it something that you will need to implement in the library.
Also, I was wondering if I could start page01 with 25, page02 with 50, to allow for possible expansion of permissions for the pages, or if they MUST be consecutive between the sets?
Beta Was this translation helpful? Give feedback.
All reactions