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


C# ZipArchive.GetEntryOrdinalIgnoreCase方法代码示例

本文整理汇总了C#中System.IO.Compression.ZipArchive.GetEntryOrdinalIgnoreCase方法的典型用法代码示例。如果您正苦于以下问题:C# ZipArchive.GetEntryOrdinalIgnoreCase方法的具体用法?C# ZipArchive.GetEntryOrdinalIgnoreCase怎么用?C# ZipArchive.GetEntryOrdinalIgnoreCase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.Compression.ZipArchive的用法示例。


在下文中一共展示了ZipArchive.GetEntryOrdinalIgnoreCase方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OpenNuspecStreamAsync

        public async Task<Stream> OpenNuspecStreamAsync(PackageInfo package)
        {
            using (var nupkgStream = await OpenNupkgStreamAsync(package))
            {
#if NET45
                if (PlatformHelper.IsMono)
                {
                    // Don't close the stream
                    var archive = Package.Open(nupkgStream, FileMode.Open, FileAccess.Read);
                    var partUri = PackUriHelper.CreatePartUri(new Uri(package.Id + ".nuspec", UriKind.Relative));
                    var entry = archive.GetPart(partUri);

                    using (var entryStream = entry.GetStream())
                    {
                        var nuspecStream = new MemoryStream((int)entryStream.Length);
                        await entryStream.CopyToAsync(nuspecStream);
                        nuspecStream.Seek(0, SeekOrigin.Begin);
                        return nuspecStream;
                    }
                }
#endif

                using (var archive = new ZipArchive(nupkgStream, ZipArchiveMode.Read, leaveOpen: true))
                {
                    var entry = archive.GetEntryOrdinalIgnoreCase(package.Id + ".nuspec");
                    using (var entryStream = entry.Open())
                    {
                        var nuspecStream = new MemoryStream((int)entry.Length);
                        await entryStream.CopyToAsync(nuspecStream);
                        nuspecStream.Seek(0, SeekOrigin.Begin);
                        return nuspecStream;
                    }
                }
            }
        }
开发者ID:jack4it,项目名称:KRuntime,代码行数:35,代码来源:PackageFolder.cs

示例2: OpenNuspecStreamFromNupkgAsync

        internal static async Task<Stream> OpenNuspecStreamFromNupkgAsync(
            string id,
            Task<Stream> openNupkgStreamAsync,
            ILogger report)
        {
            using (var nupkgStream = await openNupkgStreamAsync)
            {
                try
                {
                    using (var archive = new ZipArchive(nupkgStream, ZipArchiveMode.Read, leaveOpen: true))
                    {
                        var entry = archive.GetEntryOrdinalIgnoreCase(id + ".nuspec");
                        using (var entryStream = entry.Open())
                        {
                            var nuspecStream = new MemoryStream((int)entry.Length);
#if DNXCORE50
    // System.IO.Compression.DeflateStream throws exception when multiple
    // async readers/writers are working on a single instance of it
                            entryStream.CopyTo(nuspecStream);
#else
                            await entryStream.CopyToAsync(nuspecStream);
#endif
                            nuspecStream.Seek(0, SeekOrigin.Begin);
                            return nuspecStream;
                        }
                    }
                }
                catch (InvalidDataException)
                {
                    var fileStream = nupkgStream as FileStream;
                    if (fileStream != null)
                    {
                        report.LogWarning($"The ZIP archive {fileStream.Name.Yellow().Bold()} is corrupt");
                    }
                    throw;
                }
            }
        }
开发者ID:eerhardt,项目名称:NuGet3,代码行数:38,代码来源:PackageUtilities.cs

示例3: OpenNuspecStreamAsync

        public async Task<Stream> OpenNuspecStreamAsync(PackageInfo package)
        {
            using (var nupkgStream = await OpenNupkgStreamAsync(package))
            {
#if NET45
                if (PlatformHelper.IsMono)
                {
                    // Don't close the stream
                    var archive = Package.Open(nupkgStream, FileMode.Open, FileAccess.Read);
                    var partUri = PackUriHelper.CreatePartUri(new Uri(package.Id + ".nuspec", UriKind.Relative));
                    var entry = archive.GetPart(partUri);
                    using (var entryStream = entry.GetStream())
                    {
                        var nuspecStream = new MemoryStream((int)entryStream.Length);
                        await entryStream.CopyToAsync(nuspecStream);
                        nuspecStream.Seek(0, SeekOrigin.Begin);
                        return nuspecStream;
                    }
                }
#endif
                using (var archive = new ZipArchive(nupkgStream, ZipArchiveMode.Read, leaveOpen: true))
                {
                    var entry = archive.GetEntryOrdinalIgnoreCase(package.Id + ".nuspec");
                    using (var entryStream = entry.Open())
                    {
                        var nuspecStream = new MemoryStream((int)entry.Length);
#if NET45
                        await entryStream.CopyToAsync(nuspecStream);
#else
                        // System.IO.Compression.DeflateStream throws exception when multiple
                        // async readers/writers are working on a single instance of it
                        entryStream.CopyTo(nuspecStream);
#endif
                        nuspecStream.Seek(0, SeekOrigin.Begin);
                        return nuspecStream;
                    }
                }
            }
        }
开发者ID:jack4it,项目名称:KRuntime,代码行数:39,代码来源:PackageFeed.cs

示例4: EnsureValidPackageContents

 internal static void EnsureValidPackageContents(Stream stream, PackageInfo package)
 {
     var message = $"Response from {package.ContentUri} is not a valid NuGet package.";
     try
     {
         using (var archive = new ZipArchive(stream, ZipArchiveMode.Read, leaveOpen: true))
         {
             var entryName = $"{package.Id}.nuspec";
             var entry = archive.GetEntryOrdinalIgnoreCase(entryName);
             if (entry == null)
             {
                 throw new InvalidDataException($"{message} Cannot find required entry {entryName}.");
             }
         }
     }
     catch (InvalidDataException e)
     {
         throw new InvalidDataException(message, innerException: e);
     }
 }
开发者ID:noahfalk,项目名称:dnx,代码行数:20,代码来源:PackageUtilities.cs

示例5: OpenRuntimeStreamFromNupkgAsync

        internal static async Task<Stream> OpenRuntimeStreamFromNupkgAsync(PackageInfo package,
            Func<PackageInfo, Task<Stream>> openNupkgStreamAsync,
            IReport report)
        {
            using (var nupkgStream = await openNupkgStreamAsync(package))
            {
                try
                {
                    using (var archive = new ZipArchive(nupkgStream, ZipArchiveMode.Read, leaveOpen: true))
                    {
                        var entry = archive.GetEntryOrdinalIgnoreCase("runtime.json");
                        if (entry == null)
                        {
                            return null;
                        }
                        using (var entryStream = entry.Open())
                        {
                            var runtimeStream = new MemoryStream((int)entry.Length);
#if DNXCORE50
                            // System.IO.Compression.DeflateStream throws exception when multiple
                            // async readers/writers are working on a single instance of it
                            entryStream.CopyTo(runtimeStream);
#else
                            await entryStream.CopyToAsync(runtimeStream);
#endif
                            runtimeStream.Seek(0, SeekOrigin.Begin);
                            return runtimeStream;
                        }
                    }
                }
                catch (InvalidDataException)
                {
                    var fileStream = nupkgStream as FileStream;
                    if (fileStream != null)
                    {
                        report.WriteLine("The ZIP archive {0} is corrupt",
                            fileStream.Name.Yellow().Bold());
                    }
                    throw;
                }
            }
        }
开发者ID:noahfalk,项目名称:dnx,代码行数:42,代码来源:PackageUtilities.cs


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