public static Privileges Create(long roles) { var result = new Privileges(); foreach (var pair in _rolesMapping) { if ((roles & (int)pair.Key) != 0) { pair.Value(result); } } return(result); }