本文整理汇总了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);
}
示例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;
}
}
示例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;
}
示例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);
}