Beispiel #1
0
 /// <summary>
 /// GetAttachmentStreamAsync
 /// </summary>
 /// Get the named view as binary content as a stream
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='attachmentId'>
 /// attachment id
 /// </param>
 /// <param name='viewId'>
 /// View id from attachmentInfo
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <System.IO.Stream> GetAttachmentStreamAsync(this IAttachments operations, string attachmentId, string viewId, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.GetAttachmentWithHttpMessagesAsync(attachmentId, viewId, null, cancellationToken).ConfigureAwait(false))
     {
         return(await _result.HandleErrorAsync <System.IO.Stream>().ConfigureAwait(false));
     }
 }
        /// <summary>
        /// GetAttachment
        /// </summary>
        /// <remarks>
        /// Get the named view as binary content
        /// </remarks>
        /// <param name='operations'>
        /// The operations group for this extension method.
        /// </param>
        /// <param name='attachmentId'>
        /// attachment id
        /// </param>
        /// <param name='viewId'>
        /// View id from attachmentInfo
        /// </param>
        /// <param name='cancellationToken'>
        /// The cancellation token.
        /// </param>
        public static async Task <Stream> GetAttachmentAsync(this IAttachments operations, string attachmentId, string viewId, CancellationToken cancellationToken = default(CancellationToken))
        {
            var _result = await operations.GetAttachmentWithHttpMessagesAsync(attachmentId, viewId, null, cancellationToken).ConfigureAwait(false);

            _result.Request.Dispose();
            return(_result.Body);
        }
        /// <summary>
        /// GetAttachment
        /// </summary>
        /// Get the named view as binary content
        /// <param name='operations'>
        /// The operations group for this extension method.
        /// </param>
        /// <param name='attachmentId'>
        /// attachment id
        /// </param>
        /// <param name='viewId'>
        /// View id from attachmentInfo
        /// </param>
        /// <param name='cancellationToken'>
        /// The cancellation token.
        /// </param>
        public static async Task <byte[]> GetAttachmentAsync(this IAttachments operations, string attachmentId, string viewId, CancellationToken cancellationToken = default(CancellationToken))
        {
            using (var _result = await operations.GetAttachmentWithHttpMessagesAsync(attachmentId, viewId, null, cancellationToken).ConfigureAwait(false))
            {
                MemoryStream memoryStream = new MemoryStream();
                await _result.Body.CopyToAsync(memoryStream).ConfigureAwait(false);

                return(memoryStream.ToArray());
            }
        }
Beispiel #4
0
        /// <summary>
        /// GetAttachment
        /// </summary>
        /// Get the named view as binary content
        /// <param name='operations'>
        /// The operations group for this extension method.
        /// </param>
        /// <param name='attachmentId'>
        /// attachment id
        /// </param>
        /// <param name='viewId'>
        /// View id from attachmentInfo
        /// </param>
        /// <param name='cancellationToken'>
        /// The cancellation token.
        /// </param>
        public static async Task <byte[]> GetAttachmentAsync(this IAttachments operations, string attachmentId, string viewId, CancellationToken cancellationToken = default(CancellationToken))
        {
            using (var _result = await operations.GetAttachmentWithHttpMessagesAsync(attachmentId, viewId, null, cancellationToken).ConfigureAwait(false))
            {
                MemoryStream memoryStream = new MemoryStream();
                byte[]       buffer       = new byte[_result.Body.Length];
                await _result.Body.ReadAsync(buffer, 0, (int)_result.Body.Length).ConfigureAwait(false);

                return(buffer);
            }
        }
        /// <summary>
        /// GetAttachment
        /// </summary>
        /// Get the named view as binary content
        /// <param name='operations'>
        /// The operations group for this extension method.
        /// </param>
        /// <param name='attachmentId'>
        /// attachment id
        /// </param>
        /// <param name='viewId'>
        /// View id from attachmentInfo
        /// </param>
        /// <param name='cancellationToken'>
        /// The cancellation token.
        /// </param>
        public static async Task <byte[]> GetAttachmentAsync(this IAttachments operations, string attachmentId, string viewId, CancellationToken cancellationToken = default(CancellationToken))
        {
            using (var _result = await operations.GetAttachmentWithHttpMessagesAsync(attachmentId, viewId, null, cancellationToken).ConfigureAwait(false))
            {
                var stream = await _result.HandleErrorAsync <System.IO.Stream>().ConfigureAwait(false);

                System.IO.MemoryStream memStream = new System.IO.MemoryStream();
                await stream.CopyToAsync(memStream).ConfigureAwait(false);

                return(memStream.GetBuffer());
            }
        }
Beispiel #6
0
        /// <summary>
        /// GetAttachment
        /// </summary>
        /// Get the named view as binary content
        /// <param name='operations'>
        /// The operations group for this extension method.
        /// </param>
        /// <param name='attachmentId'>
        /// attachment id
        /// </param>
        /// <param name='viewId'>
        /// View id from attachmentInfo
        /// </param>
        /// <param name='cancellationToken'>
        /// The cancellation token.
        /// </param>
        public static async Task <byte[]> GetAttachmentAsync(this IAttachments operations, string attachmentId, string viewId, CancellationToken cancellationToken = default(CancellationToken))
        {
            var _result = await operations.GetAttachmentWithHttpMessagesAsync(attachmentId, viewId, null, cancellationToken).ConfigureAwait(false);

            return(_result.HandleError <byte[]>());
        }