I'm looking for a way to create some kind of value type hierarchical class structure. I know that enums do not support inheritence since they are value types and are therefore sealed, so I'm probably looking for some kind of static class implementation.
My purpose for this is to redefine roles in this ASP.NET application I'm working on. Currently the roles are string constants (ROLE_ADMIN, ROLE_USER, etc.) and are put in the session and checked throughout the application something like so: Person.getRole() == ROLE_ADMIN (which is actually a string comparison). I'd like to refactor this so that I can have type safety, as well as some kind of polymorphic behavior as desribed below.
Consider the following role structure:
user1
Group1
user2
Admin
User3
If a person's role is set to Group1, but a certain element on the page is only visible by user1, then I want the statement Person.getRole() == user1 to be true.
EDIT:
Thinking of the above structure as a tree, I wanted to be able to both define a user in terms of a leaf or a node, and check permissions in terms of a leaf or a node. However that raises a dilemma, does the checking of permissions in terms of a node check if the user belongs to a group (group1), or IS a group (Admin). I think the problem is that naming the root node of my tree as 'Admin' is misleading, since nodes should be thought of as groups and not as roles themselves. The root node should be something like 'All', and when it is defined as 'All' would inherit all the leaves of the tree and would therefore belong to all the groups.