00(0) And Read = 0 01(1) And Read = Read 10(2) And Read = 0 11(3) And Read = Read 00(0) And Write = 0 01(1) And Write = 0 10(2) And Write = Write 11(3) And Write = Write
下面给出示例代码:
权限定义类(要有枚举类型该多好啊...)
Class PermissionType
Public Read Public Write Public Delete
Private Sub Class_Initialize Read = 1 Write = 2 Delete = 4 End Sub
End Class 权限类
Class PermissionSetComponent
Private intValue
Public Property Get Read() Read = GetValue(Permission.Read) End Property
Public Property Let Read(arg) Call SetValue(Permission.Read, arg) End Property
Public Property Get Write() Write = GetValue(Permission.Write) End Property
Public Property Let Write(arg) Call SetValue(Permission.Write, arg) End Property
Public Property Get Delete() Delete = GetValue(Permission.Delete) End Property
Public Property Let Delete(arg) Call SetValue(Permission.Delete, arg) End Property
Public Property Get Value() Value = intValue End Property
Public Property Let Value(arg) intValue = arg End Property
Public Function GetValue(intType) GetValue = (Value and intType) = intType
End Function
Public Sub SetValue(intType, boolValue) IF (boolValue) Then Value = Value Or intType Else Value = Value And (Not intType) End IF End Sub
End Class 运用示例代码:
Dim Permission : Set Permission = new PermissionType
Dim PermissionSet : Set PermissionSet = new PermissionSetComponent PermissionSet.Value = 0 w("Read:") PermissionSet.Read = false w(PermissionSet.Value " " PermissionSet.Read)