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


C# ZipPackage.GetStream方法代码示例

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


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

示例1: Push

        public void Push(string url, string key, Stream stream)
        {
            var package = new ZipPackage(stream);
            stream = package.GetStream();

            var server = new PackageServer(url, "SymbolSource");
            server.PushPackage(key, package, stream.Length, 5000, false);
        }
开发者ID:n3rd,项目名称:SymbolSource.Community,代码行数:8,代码来源:TestHelper.cs

示例2: ReadPackageFile

        StoredPackage ReadPackageFile(string filePath)
        {
            try
            {
                var metadata = new ZipPackage(filePath);

                using (var hashStream = metadata.GetStream())
                {
                    var hash = HashCalculator.Hash(hashStream);

                    var packageMetadata = new PackageMetadata
                    {
                       Id = metadata.Id,
                        Version = metadata.Version.ToString(),
                        Hash = hash
                    };

                    return new StoredPackage(packageMetadata, filePath);
                }
            }
            catch (FileNotFoundException)
            {
                return null;
            }
            catch (IOException)
            {
                return null;
            }
            catch (FileFormatException)
            {
                return null;
            }
        }
开发者ID:hognefossland,项目名称:Calamari,代码行数:33,代码来源:PackageStore.cs

示例3: ConvertToVersion

        public static Version ConvertToVersion(Stream stream)
        {
            var package = new ZipPackage(stream);
            stream = package.GetStream();

            var version = new Version
                              {
                                  Project = package.Id,
                                  Name = package.Version.ToString(),
                              };

            var metadata = new List<MetadataEntry>();
            var metadataWrapper = new MetadataWrapper(metadata);

            if (!package.Authors.IsEmpty())
                metadataWrapper["Authors"] = String.Join(",", package.Authors);

            if (!string.IsNullOrEmpty(package.Copyright))
                metadataWrapper["Copyrights"] = package.Copyright;

            if (!string.IsNullOrEmpty(package.Description))
                metadataWrapper["Description"] = package.Description;

            if (package.IconUrl != null)
                metadataWrapper["IconUrl"] = package.IconUrl.ToString();

            if (!string.IsNullOrEmpty(package.Language))
                metadataWrapper["Language"] = package.Language;

            if (package.LicenseUrl != null)
                metadataWrapper["LicenseUrl"] = package.LicenseUrl.ToString();

            if (!package.Owners.IsEmpty())
                metadataWrapper["Owners"] = String.Join(",", package.Owners);

            if (package.ProjectUrl != null)
                metadataWrapper["ProjectUrl"] = package.ProjectUrl.ToString();

            if (!string.IsNullOrEmpty(package.ReleaseNotes))
                metadataWrapper["ReleaseNotes"] = package.ReleaseNotes;

            metadataWrapper["RequireLicenseAcceptance"] = package.RequireLicenseAcceptance.ToString();

            if (!string.IsNullOrEmpty(package.Summary))
                metadataWrapper["Summary"] = package.Summary;

            if (!string.IsNullOrEmpty(package.Tags))
                metadataWrapper["Tags"] = package.Tags;

            if (package.DependencySets.SelectMany(ConvertDependencySetToStrings).Any())
                metadataWrapper["Dependencies"] = String.Join("|", package.DependencySets.SelectMany(ConvertDependencySetToStrings));

            if (!string.IsNullOrEmpty(package.Title))
                metadataWrapper["Title"] = package.Title;

            metadataWrapper["PackageSize"] = stream.Length.ToString();
            metadataWrapper["PackageHashAlgorithm"] = "SHA512";

            stream.Seek(0, SeekOrigin.Begin);
            using (var hasher = new SHA512Managed())
                    metadataWrapper["PackageHash"] = Convert.ToBase64String(hasher.ComputeHash(stream));

            metadataWrapper["DownloadCount"] = "000000";
            metadataWrapper["CreatedDate"] = DateTime.UtcNow.ToString("s");

            version.Metadata = metadata.ToArray();

            return version;
        }
开发者ID:n3rd,项目名称:SymbolSource.Community,代码行数:69,代码来源:NuGetTranslator.cs

示例4: SyndicateAsync

        /// <summary>
        /// Syndicates the nupkg stream for use within the system.
        /// </summary>
        /// <param name="stream">The stream.</param>
        /// <returns></returns>
        public async Task<Models.Release> SyndicateAsync(Stream stream)
        {
            ZipPackage package = new ZipPackage(stream);
            var storageFilename = string.Format("{0}.{1}.nupkg", package.Id, package.Version);

            Models.Release release = await _releaseStore.GetAsync(package.Id, package.Version.ToString());

            if (release == null)
            {
                // assume we need to publish a new release.
                release = _releaseStore.Create();
            }

            if (stream.CanSeek)
            {
                stream.Seek(0, 0);
            }

            var streamSHA = Utilities.CalculateChecksum(stream);
            if (!streamSHA.Equals(release.SHA1))
            {
                release.Description = package.Description;
                release.IconUrl = package.IconUrl;
                release.Id = package.Id;
                release.Listed = package.Listed;
                release.Published = DateTimeOffset.Now;
                release.ReleaseNotes = package.ReleaseNotes;
                release.Summary = package.Summary;
                release.Tags = package.Tags;
                release.Title = package.Title;
                release.Version = package.Version.ToString();
                release.SHA1 = streamSHA;

                // update store.
                await _fileService.DeleteAsync(storageFilename);

                release.RelativeUri = await _fileService.StoreAsync(storageFilename, package.GetStream());
            }

            return await _releaseStore.StoreAsync(release);
        }
开发者ID:dealproc,项目名称:Drey,代码行数:46,代码来源:PackageService.cs


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