Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Static method in the public class
Message
From
09/08/2016 07:18:21
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 5.0
OS:
Windows 10
Database:
MS SQL Server
Miscellaneous
Thread ID:
01639234
Message ID:
01639237
Views:
54
>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.

Have not understood completely, but

(1) You can add the same method with a different signature if necessary

(2) Rights class can be a static property of OperatorSession class - if needed

(3) You can always instantiate an object in a static method
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform