J
J055
Hi
The function below accepts an Enum value 'AccountRoles' and should return an
array of Permissions which is also an Enum. When the AccountRoles is
AccountRoles.Administrator it should always return the full list of values
from the Permissions enum. Is there a clean way to do this?
public static Permissions[] GetPermissions(AccountRoles role)
{
switch (role)
{
case AccountRoles.Administrator:
return new Permissions[] { }; // need to return an array
of all Permissions enum values
case AccountRoles.Publisher:
return new Permissions[] {
Permissions.CreateAccount,
Permissions.DeleteAccount,
Permissions.EditAccount,
Permissions.ViewAccounts
};
}
}
Many thanks
Andrew
The function below accepts an Enum value 'AccountRoles' and should return an
array of Permissions which is also an Enum. When the AccountRoles is
AccountRoles.Administrator it should always return the full list of values
from the Permissions enum. Is there a clean way to do this?
public static Permissions[] GetPermissions(AccountRoles role)
{
switch (role)
{
case AccountRoles.Administrator:
return new Permissions[] { }; // need to return an array
of all Permissions enum values
case AccountRoles.Publisher:
return new Permissions[] {
Permissions.CreateAccount,
Permissions.DeleteAccount,
Permissions.EditAccount,
Permissions.ViewAccounts
};
}
}
Many thanks
Andrew