Net.Pkcs11Interop.HighLevelAPI81.ObjectAttribute.GetValueAsString C# (CSharp) 메소드

GetValueAsString() 공개 메소드

Reads value of attribute and returns it as string
public GetValueAsString ( ) : string
리턴 string
        public string GetValueAsString()
        {
            if (this._disposed)
                throw new ObjectDisposedException(this.GetType().FullName);

            string value = null;
            CkaUtils.ConvertValue(ref _ckAttribute, out value);
            return value;
        }

Usage Example

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

            string value = "Hello world";

            // Create attribute with string value
            using (ObjectAttribute attr = new ObjectAttribute(CKA.CKA_LABEL, value))
            {
                Assert.IsTrue(attr.Type == (ulong)CKA.CKA_LABEL);
                Assert.IsTrue(attr.GetValueAsString() == value);
            }

            value = null;

            // Create attribute with null string value
            using (ObjectAttribute attr = new ObjectAttribute(CKA.CKA_LABEL, value))
            {
                Assert.IsTrue(attr.Type == (ulong)CKA.CKA_LABEL);
                Assert.IsTrue(attr.GetValueAsString() == value);
            }
        }