It seems likely that your code will eventually compile a list of user interface elements to hide or perform this action, and then perform these actions based on the current role. Sort of
Dictionary<Control, Action<Control, string>> actions = new Dictionary<Control, Action<Control, string>>
{
{ button, (c, r) => c.Enabled = (r == "administrator") },
// etc.
};
How you compile this list is primarily your question. AOP structures definitely help in sharing problems, but resolving homebrew will not be impossible. I think something like:
EnableForRoleAttribute role.- (, , , , ,
RoleVaryingAttribute ). - ,
Control, Control EnableForRoleAttribute. - !
Enabled .
Enabled, , lambdas :( SetPropertyIfInRoleAttribute role, propertyName propertyValue .
, AOP , PostSharp , . homebrew .