Net.Pkcs11Interop.HighLevelAPI81.ObjectAttribute.GetValueAsBool C# (CSharp) Method

GetValueAsBool() public method

Reads value of attribute and returns it as bool
public GetValueAsBool ( ) : bool
return bool
        public bool GetValueAsBool()
        {
            if (this._disposed)
                throw new ObjectDisposedException(this.GetType().FullName);

            bool value = false;
            CkaUtils.ConvertValue(ref _ckAttribute, out value);
            return value;
        }

Usage Example

        public void _04_BoolAttributeTest()
        {
            if (Platform.UnmanagedLongSize != 8 || Platform.StructPackingSize != 1)
                Assert.Inconclusive("Test cannot be executed on this platform");

            bool value = true;

            // Create attribute with bool value
            using (ObjectAttribute attr = new ObjectAttribute(CKA.CKA_TOKEN, value))
            {
                Assert.IsTrue(attr.Type == (ulong)CKA.CKA_TOKEN);
                Assert.IsTrue(attr.GetValueAsBool() == value);
            }
        }