>>Hi everybody,
>>
>>We have the following class:
>>
>>
>> [Serializable]
>> public class OperatorSession
>> {
>> public OperatorSession()
>> {
>> Rights = new string[0];
>> Roles = new List<SecRole>();
>> }
>>
>> public string OpCode { get; set; }'
>> etc.
>>
>>
>> public static bool IsAdmin(string opCode)
>> {
>> return !String.IsNullOrEmpty(opCode) && opCode.Trim().ToLower() == SysManagerConstants.ADMIN_OPCODE.ToLower();
>> }
>>
>>
>>The problem here is that IsAdmin definition changed. Now in addition of the opCode being some specific code this method should also return true when the operator has the following role X_SYSADMIN.
>>
>>I am not able to add a check for Rights.contains in the static method and so I'm at loss as how can I check what I need to check.
>>
>>My other problem is that OperatorSession class is defined in the Models project. This project only contains classes definitions and it doesn't reference anything else. There is another project called Data which has Models as a reference. So, from the OperatorSession I can not even access DbSet to try to get an instance of the operator by the code to check operator's roles.
>>
>>I also checked that we do use something like this in the code:
>>
>>return OperatorSession.IsAdmin(id) || rights.Contains("SEC_OEDIT");
>>
>>
>>
>>I guess I need to create a different non static method to check if operator is an admin.
>>
>>Thanks in advance.
>>
>>UPDATE. Apparently I would have to create another static method and will have to pass operator's rights to it. Then I would need to check all calls to the original method and somehow adjust.
>
>Why do you use a static method?
> An instance of the class is obviously being instantiated anyway so I see no real benefit?
Because you don't have to remember where you've kept that instance ?
Gregory