Custom IPrincipal with a Generic - sloan

26-Jun-07 12:13:55
I'm working on a custom IPrincipal.

Sometimes I use the "good ole" MS system of strings.

Lately, I've been storing my roles and rights as Guids.

Check out the below code.

I'm not sure if this is the way to go or not.

What stinks is that I don't see how to keep IRolesAndRightsPrincipalT<T> to
be ~only string or guid based.  ( The "where" seems to only like base class
stuff  for trying to constrain <T>)

Aka, somebody could right a

public interface IRolesAndRightsPrincipalABC :
IRolesAndRightsPrincipalT<Employee>
{

}

which really doesn't make any sense.



This is a very , very "top level" interface I'm trying to create, so that it
fills IPrincipal needs throughout the company.
There might be 20-25 concrete implementations.  ( << Don't ask )



I don't know.  I'm just looking for some "This is dumb" or "That's ok"
comments.



public interface IRolesAndRightsPrincipalT<T> :
System.Security.Principal.IPrincipal

{

bool IsInRole(T role);

bool IsInAnyRole(T[] roles);

bool IsInAllRoles(T[] roles);

bool HasRight(T right);

bool HasAnyRight(T[] rights);

bool HasAllRights(T[] rights);

}



public interface IRolesAndRightsPrincipalString :
IRolesAndRightsPrincipalT<string>

{

}

public interface IRolesAndRightsPrincipalGuid :
IRolesAndRightsPrincipalT<System.Guid>

{

}
reply
Custom IPrincipal with a Generic - sloan 26-Jun-07
        Re: Custom IPrincipal with a Generic - Nicholas Paldino [.NET/C# MVP] 26-Jun-07
                Re: Custom IPrincipal with a Generic - sloan 26-Jun-07

Different Project types
  

Search

search




Purchase