當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。