本文整理汇总了C#中Windows.AsStreamForRead方法的典型用法代码示例。如果您正苦于以下问题:C# Windows.AsStreamForRead方法的具体用法?C# Windows.AsStreamForRead怎么用?C# Windows.AsStreamForRead使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Windows
的用法示例。
在下文中一共展示了Windows.AsStreamForRead方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Parse
public TheTvDbUpdateContainer Parse(Windows.Storage.Streams.IInputStream updateContainerStream, TheTvDbInterval interval)
#endif
{
if (updateContainerStream == null) throw new ArgumentNullException(nameof(updateContainerStream));
#if WINDOWS_PORTABLE || WINDOWS_DESKTOP
using (var archive = new ZipArchive(updateContainerStream, ZipArchiveMode.Read))
#elif WINDOWS_UAP
using (var archive = new ZipArchive(updateContainerStream.AsStreamForRead(), ZipArchiveMode.Read))
#endif
{
var entryName = $"updates_{interval.ToApiString()}.xml";
var updateContainerRaw = archive.GetEntry(entryName).ReadToEnd();
return ParseUncompressed(updateContainerRaw);
}
}
示例2: SendAsync
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();
}
示例3: ParseFull
public async Task<TheTvDbSeries> ParseFull(Windows.Storage.Streams.IInputStream fullSeriesCompressedStream, TheTvDbLanguage language)
#endif
{
if (fullSeriesCompressedStream == null) throw new ArgumentNullException(nameof(fullSeriesCompressedStream));
string seriesRaw;
string actorsRaw;
string bannersRaw;
#if WINDOWS_PORTABLE || WINDOWS_DESKTOP
using (var archive = new ZipArchive(fullSeriesCompressedStream, ZipArchiveMode.Read))
#elif WINDOWS_UAP
using (var archive = new ZipArchive(fullSeriesCompressedStream.AsStreamForRead(), ZipArchiveMode.Read))
#endif
{
// Throw ParseException if series metadata cannot be retrieved from the compressed file.
seriesRaw = archive.GetEntry(language.ToShortString() + ".xml").ReadToEnd();
if (seriesRaw == null) throw new TheTvDbParseException("Compressed file does not have a series metadata file.");
actorsRaw = archive.GetEntry("actors.xml").ReadToEnd();
bannersRaw = archive.GetEntry("banners.xml").ReadToEnd();
}
// Create parse tasks if string not null
var seriesTask = Task.Run(() => Parse(seriesRaw));
var actorsTask = actorsRaw != null ?
Task.Run(() => _actorParseService.Parse(actorsRaw)) :
null;
var bannersTask = bannersRaw != null ?
Task.Run(() => _bannerParseService.Parse(bannersRaw)) :
null;
// Create tasks list to await it
var tasks = new List<Task> { seriesTask };
if (actorsTask != null) tasks.Add(actorsTask);
if (bannersTask != null) tasks.Add(bannersTask);
await Task.WhenAll(tasks);
var series = seriesTask.Result;
if (actorsTask != null) series.Actors = actorsTask.Result;
if (bannersTask != null) series.Banners = bannersTask.Result;
return series;
}