I have six variables of type String, they contain 0/1 value retrieved from a DB field bit.
So,these variables are value of radio boxes, that have Y=1 | N=0.
Now, I have a Varilable, that accept one or more enumerator values, they are separated by pipe “|”.
if (bool.Parse(mht_ReadAccess) && bool.Parse(mht_WriteAccess))
{
var grantAccessRequest = new GrantAccessRequest
{
PrincipalAccess = new PrincipalAccess
{
AccessMask = AccessRights.WriteAccess | AccessRights.ReadAccess,
Principal = userreference
},
Target = recordentityreference
};
}
Now, this is a static way to solve this problem. If I have 6 variables like “mht_WriteAccess” , how can I check how many of them are set on true, and automatically change the situation for the “AccessMask” variable, and so pass all the right enum values with pipe.
I want to know if there’s a way to do this automatically, maybe with any cycle?
1 Answer