在 C# 中这是允许的:
[Flags]
private enum PermissionType
{
Read = 0x0001,
Write = 0x0002,
Execute = 0x0004,
All = Read | Write | Execute
}
这允许:
private bool TestPerm(PermissionType p)
{
if( PermissionType.Read & p) return true; // user can read
if( PermissionType.Write & p) return true; // user can write
if( PermissionType.Execute & p) return true; // user can Execute
//etc
}
可以这样调用:
Testperm( PermissionType.Read | PermissionType.Write );
我知道 ObjectScript 中没有枚举 DataType,但我认为具有此类属性的常规类应该可以工作......
Class Sample.AcknowledgeType Extends %RegisteredObject
{
Property Read As %Integer [ InitialExpression = 1 ];
Property Write As %Integer [ InitialExpression = 2 ];
Property Execute As %Integer [ InitialExpression = 4 ];
Property All As %Integer [ InitialExpression = 7 ];
}
这是我得到的。如何编写 TestPerm 方法?