Beispiel #1
0
 public static extern void IDataReadFromSelfEncryptorNative(
     IntPtr appPtr,
     ulong seHandle,
     ulong fromPos,
     ulong len,
     IntPtr self,
     IDataReadFromSelfEncryptorCb callback);
Beispiel #2
0
 public void IDataReadFromSelfEncryptor(
     IntPtr appPtr,
     ulong seHandle,
     ulong fromPos,
     ulong len,
     IntPtr self,
     IDataReadFromSelfEncryptorCb callback)
 {
     IDataReadFromSelfEncryptorNative(appPtr, seHandle, fromPos, len, self, callback);
 }
Beispiel #3
0
        public static Task <List <byte> > IDataReadFromSelfEncryptorAsync(ulong seHandle, ulong fromPos, ulong len)
        {
            var tcs = new TaskCompletionSource <List <byte> >();
            IDataReadFromSelfEncryptorCb callback = null;

            callback = (self, result, dataPtr, dataLen) => {
                if (result.ErrorCode != 0)
                {
                    tcs.SetException(result.ToException());
                    CallbackManager.Unregister(callback);
                    return;
                }
                var data = dataPtr.ToList <byte>(dataLen);
                tcs.SetResult(data);
                CallbackManager.Unregister(callback);
            };

            CallbackManager.Register(callback);
            NativeBindings.IDataReadFromSelfEncryptor(Session.AppPtr, seHandle, fromPos, len, Session.UserData, callback);

            return(tcs.Task);
        }