c# - Prepare enum list and find an enum value from List<enum> -


i decided write below code access control list permission check.

my database return record employeedetfeature,create,edit

i parse create , add feature acl enum list.

also need find later.

public enum acl {      create,     delete,     edit,     update,     execute }     public class feature {     public int id { get; set; }     public string name { get; set; }     public list<acl> aclitems { get; set; } }     public static class permissionhelper {     public static bool checkpermission(role role, string featurename, acl acl)     {         feature feature = role.features.find(f =>f.name == featurename);         if (feature != null)         {             //find acl enum , if exists return true             return true;         }         return false;     } } 

how make enum collection preparation , find same later checking permission.

find acl enum , if exists return true

something this?

bool b= enum.getvalues(typeof(acl)).cast<acl>().any(e => e == acl); 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -