protected override sealed bool ReleaseHandle()
{
if (_parentHandle != null)
{
_parentHandle.DangerousRelease();
_parentHandle = null;
SetHandle(IntPtr.Zero);
return true;
}
else if (_isNcrypt)
{
ErrorCode errorCode = Interop.NCrypt.NCryptFreeObject(handle);
return errorCode == ErrorCode.ERROR_SUCCESS;
}
else
{
bool success = Interop.Crypt32.CryptReleaseContext(handle, 0);
return success;
}
}