/// <summary> /// Extension method to perform sync/async version of DataServiceContext.GetReadStream dynamically /// </summary> /// <param name="context">The context to call get read stream on</param> /// <param name="continuation">The asynchronous continuation</param> /// <param name="async">A value indicating whether or not to use async API</param> /// <param name="entity">The entity to get the read stream for</param> /// <param name="streamName">The name of the stream or null to indicate the default stream</param> /// <param name="args">The wrapped args to the request</param> /// <param name="onCompletion">A callback for when the call completes</param> public static void GetReadStream(this WrappedDataServiceContext context, IAsyncContinuation continuation, bool async, WrappedEntityInstance entity, string streamName, WrappedObject args, Action <WrappedDataServiceStreamResponse> onCompletion) { ExceptionUtilities.CheckArgumentNotNull(context, "context"); if (streamName == null) { AsyncHelpers.InvokeSyncOrAsyncMethodCall <WrappedDataServiceStreamResponse>(continuation, async, () => context.GetReadStream(entity, args), c => context.BeginGetReadStream(entity, args, c, null), r => context.EndGetReadStream(r), onCompletion); } else { AsyncHelpers.InvokeSyncOrAsyncMethodCall <WrappedDataServiceStreamResponse>(continuation, async, () => context.GetReadStream(entity, streamName, args), c => context.BeginGetReadStream(entity, streamName, args, c, null), r => context.EndGetReadStream(r), onCompletion); } }