jump to navigation

SimpleACL Class February 17 2006

Public Class clsSimpleACL

   Private __intThisACLValue As Integer

   Private Enum ACL As Integer
      Task_A = 1
      Task_B = 2
      Task_C = 4
      Task_D = 8
      Task_E = 16
   End Enum

   Public Property ACLValue() As Integer
      Get
         Return (__intThisACLValue)
      End Get
      Set(ByVal Value As Integer)
         __intThisACLValue = Value
      End Set
   End Property
   Public ReadOnly Property ACLItem_TaskA() As Integer
      Get
         Return (Me.ACL.Task_A)
      End Get
   End Property
   Public ReadOnly Property ACLItem_TaskB() As Integer
      Get
         Return (Me.ACL.Task_B)
      End Get
   End Property
   Public ReadOnly Property ACLItem_TaskC() As Integer
      Get
         Return (Me.ACL.Task_C)
      End Get
   End Property
   Public ReadOnly Property ACLItem_TaskD() As Integer
      Get
         Return (Me.ACL.Task_D)
      End Get
   End Property
   Public ReadOnly Property ACLItem_TaskE() As Integer
      Get
         Return (Me.ACL.Task_E)
      End Get
   End Property

   Public Sub New()
      Me.__intThisACLValue = 0
   End Sub
   Public Sub New(ByVal intACLValue As Integer)
      Me.__intThisACLValue = intACLValue
   End Sub

   Public Sub allowTask(ByVal intACLItem As Integer)
      If (isTaskAllowed(intACLItem) = False) Then
         Me.__intThisACLValue += intACLItem
      End If
   End Sub
   Public Sub denyTask(ByVal intACLItem As Integer)
      If (isTaskAllowed(intACLItem) = True) Then
         Me.__intThisACLValue -= intACLItem
      End If
   End Sub
   Public Function isTaskAllowed(ByVal intACLItem As Integer) As Boolean
      Dim bolRet As Boolean = False
      If (Me.__intThisACLValue > 0) Then
         If ((Me.__intThisACLValue And intACLItem) = intACLItem) Then
            bolRet = True
         End If
      End If
      Return (bolRet)
   End Function

End Class

Comments

Sorry comments are closed for this entry