public IAsyncOperation <SAP.Supportability.IUploadResult> SendAsync(IReadOnlyDictionary <string, string> headers, Windows.Storage.Streams.IInputStream payload) { return(Task.Run <SAP.Supportability.IUploadResult>(async() => { var result = await this.clientRef.SendAsync(() => { var request = new HttpRequestMessage(HttpMethod.Post, "http://smpqa-win12-03.sybase.com:8080/" + this.urlPostfix) { Content = new StreamContent(payload.AsStreamForRead()) }; foreach (var header in headers) { request.Content.Headers.TryAddWithoutValidation(header.Key, header.Value); } return request; }); return new UploadResult() { ResponseStatusCode = (int)result.StatusCode, Hint = await result.Content.ReadAsStringAsync() }; }).AsAsyncOperation()); }
public ImageSource GetImageSourceFromPath(string filePath) { var file = this.localFolder.GetFileAsync(filePath).AsTask().Result; Windows.Storage.Streams.IInputStream stream = file.OpenReadAsync().AsTask().Result; return(ImageSource.FromStream(() => stream.AsStreamForRead())); }
private void OnPickSingleFile(IAsyncOperation <StorageFile> info, AsyncStatus status) { var storageFile = info.GetResults(); file = storageFile; storageFile.OpenReadAsync() .Completed = (openReadInfo, openReadStatus) => { Windows.Storage.Streams.IInputStream inputStream = openReadInfo.GetResults(); System.IO.Stream stream = inputStream.AsStreamForRead(); System.IO.StreamReader reader = new StreamReader(stream); this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => txtbox.Text = reader.ReadToEnd()); }; }