Esempio n. 1
0
        private static ICancellableAsyncResult CompleteSynchronously(AsyncCallback callback, object state)
        {
            ICancellableAsyncResult result = new CompletedCancellableAsyncResult(state);

            InvokeCallback(callback, result);
            return(result);
        }
        public void SetAsyncResult(CompletedCancellableAsyncResult result)
        {
            if (_result != null)
            {
                throw new InvalidOperationException("SetAsyncResult has already been called.");
            }

            _result = result;
        }
        public void SetAsyncResult(CompletedCancellableAsyncResult result)
        {
            if (_result != null)
            {
                throw new InvalidOperationException("SetAsyncResult has already been called.");
            }

            _result = result;
        }
        public static IReturnsResult <CloudBlobStream> ReturnsCompletedSynchronously(
            this IReturnsThrows <CloudBlobStream, IAsyncResult> returnsThrows)
        {
            if (returnsThrows == null)
            {
                throw new ArgumentNullException("returnsThrows");
            }

            return(returnsThrows.Returns <AsyncCallback, object>((callback, state) =>
            {
                IAsyncResult result = new CompletedCancellableAsyncResult(state);
                InvokeCallback(callback, result);
                return result;
            }));
        }
        public static IReturnsResult <Stream> ReturnsCompletedSynchronously(
            this ISetup <Stream, IAsyncResult> setup)
        {
            if (setup == null)
            {
                throw new ArgumentNullException(nameof(setup));
            }

            return(setup.Returns <byte[], int, int, AsyncCallback, object>((a1, a2, a3, callback, state) =>
            {
                IAsyncResult result = new CompletedCancellableAsyncResult(state);
                InvokeCallback(callback, result);
                return result;
            }));
        }
        public static IReturnsResult<CloudBlobStream> ReturnsCompletedSynchronously(
            this IReturnsThrows<CloudBlobStream, ICancellableAsyncResult> returnsThrows)
        {
            if (returnsThrows == null)
            {
                throw new ArgumentNullException("returnsThrows");
            }

            return returnsThrows.Returns<AsyncCallback, object>((callback, state) =>
            {
                ICancellableAsyncResult result = new CompletedCancellableAsyncResult(state);
                InvokeCallback(callback, result);
                return result;
            });
        }
Esempio n. 7
0
        public static IReturnsResult <CloudBlobStream> ReturnsCompletedSynchronously(
            this ISetup <CloudBlobStream, IAsyncResult> setup, CompletedCancellationSpy spy)
        {
            if (setup == null)
            {
                throw new ArgumentNullException("setup");
            }

            return(setup.Returns <AsyncCallback, object>((callback, state) =>
            {
                CompletedCancellableAsyncResult result = new CompletedCancellableAsyncResult(state);
                spy.SetAsyncResult(result);
                InvokeCallback(callback, result);
                return result;
            }));
        }
        public static IReturnsResult<CloudBlobStream> ReturnsCompletedSynchronously(
            this ISetup<CloudBlobStream, ICancellableAsyncResult> setup, CompletedCancellationSpy spy)
        {
            if (setup == null)
            {
                throw new ArgumentNullException("setup");
            }

            return setup.Returns<AsyncCallback, object>((callback, state) =>
            {
                CompletedCancellableAsyncResult result = new CompletedCancellableAsyncResult(state);
                spy.SetAsyncResult(result);
                InvokeCallback(callback, result);
                return result;
            });
        }
 private static ICancellableAsyncResult CompleteSynchronously(AsyncCallback callback, object state)
 {
     ICancellableAsyncResult result = new CompletedCancellableAsyncResult(state);
     InvokeCallback(callback, result);
     return result;
 }