AttachmentsExtensions.cs
1 // Code generated by Microsoft (R) AutoRest Code Generator 0.16.0.0
2 // Changes may cause incorrect behavior and will be lost if the code is
3 // regenerated.
4 
5 namespace Microsoft.Bot.Connector
6 {
7  using System;
8  using System.Collections;
9  using System.Collections.Generic;
10  using System.Threading;
11  using System.Threading.Tasks;
12  using Microsoft.Rest;
13 
14 
18  public static partial class AttachmentsExtensions
19  {
30  public static AttachmentInfo GetAttachmentInfo(this IAttachments operations, string attachmentId)
31  {
32  return Task.Factory.StartNew(s => ((IAttachments)s).GetAttachmentInfoAsync(attachmentId), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
33  }
34 
48  public static async Task<AttachmentInfo> GetAttachmentInfoAsync(this IAttachments operations, string attachmentId, CancellationToken cancellationToken = default(CancellationToken))
49  {
50  using (var _result = await operations.GetAttachmentInfoWithHttpMessagesAsync(attachmentId, null, cancellationToken).ConfigureAwait(false))
51  {
52  return await _result.HandleErrorAsync<AttachmentInfo>().ConfigureAwait(false);
53  }
54  }
55 
69  public static byte[] GetAttachment(this IAttachments operations, string attachmentId, string viewId)
70  {
71  return Task.Factory.StartNew(s => ((IAttachments)s).GetAttachmentAsync(attachmentId, viewId), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
72  }
73 
90  public static async Task<byte[]> GetAttachmentAsync(this IAttachments operations, string attachmentId, string viewId, CancellationToken cancellationToken = default(CancellationToken))
91  {
92  using (var _result = await operations.GetAttachmentWithHttpMessagesAsync(attachmentId, viewId, null, cancellationToken).ConfigureAwait(false))
93  {
94  var stream = await _result.HandleErrorAsync<System.IO.Stream>().ConfigureAwait(false);
95  System.IO.MemoryStream memStream = new System.IO.MemoryStream();
96  await stream.CopyToAsync(memStream).ConfigureAwait(false);
97  return memStream.ToArray();
98  }
99  }
100 
114  public static System.IO.Stream GetAttachmentStream(this IAttachments operations, string attachmentId, string viewId)
115  {
116  return Task.Factory.StartNew(s => ((IAttachments)s).GetAttachmentStreamAsync(attachmentId, viewId), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
117  }
118 
135  public static async Task<System.IO.Stream> GetAttachmentStreamAsync(this IAttachments operations, string attachmentId, string viewId, CancellationToken cancellationToken = default(CancellationToken))
136  {
137  using (var _result = await operations.GetAttachmentWithHttpMessagesAsync(attachmentId, viewId, null, cancellationToken).ConfigureAwait(false))
138  {
139  return await _result.HandleErrorAsync<System.IO.Stream>().ConfigureAwait(false);
140  }
141  }
142 
143  }
144 }
Task< HttpOperationResponse< object > > GetAttachmentWithHttpMessagesAsync(string attachmentId, string viewId, Dictionary< string, List< string >> customHeaders=null, CancellationToken cancellationToken=default(CancellationToken))
GetAttachment
static async Task< AttachmentInfo > GetAttachmentInfoAsync(this IAttachments operations, string attachmentId, CancellationToken cancellationToken=default(CancellationToken))
GetAttachmentInfo
Attachments operations.
Definition: IAttachments.cs:18
Task< HttpOperationResponse< object > > GetAttachmentInfoWithHttpMessagesAsync(string attachmentId, Dictionary< string, List< string >> customHeaders=null, CancellationToken cancellationToken=default(CancellationToken))
GetAttachmentInfo
static async Task< System.IO.Stream > GetAttachmentStreamAsync(this IAttachments operations, string attachmentId, string viewId, CancellationToken cancellationToken=default(CancellationToken))
GetAttachmentStreamAsync
static async Task< byte[]> GetAttachmentAsync(this IAttachments operations, string attachmentId, string viewId, CancellationToken cancellationToken=default(CancellationToken))
GetAttachment
static AttachmentInfo GetAttachmentInfo(this IAttachments operations, string attachmentId)
GetAttachmentInfo
static byte[] GetAttachment(this IAttachments operations, string attachmentId, string viewId)
GetAttachment
static System.IO.Stream GetAttachmentStream(this IAttachments operations, string attachmentId, string viewId)
GetAttachmentStream