当前位置: 首页>>代码示例>>C#>>正文


C# Windows.AsStreamForRead方法代码示例

本文整理汇总了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);
            }
        }
开发者ID:StuartMeeks,项目名称:TheTVDBSharp,代码行数:16,代码来源:TheTvDbUpdateParser.cs

示例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();
        }
开发者ID:viru48,项目名称:sap_mobile_platform_windows,代码行数:26,代码来源:SupportabilityContext.cs

示例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;
        }
开发者ID:StuartMeeks,项目名称:TheTVDBSharp,代码行数:45,代码来源:TheTvDbSeriesParser.cs


注:本文中的Windows.AsStreamForRead方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。