本文整理汇总了C#中SourceRepository.GetPackageMetadataById方法的典型用法代码示例。如果您正苦于以下问题:C# SourceRepository.GetPackageMetadataById方法的具体用法?C# SourceRepository.GetPackageMetadataById怎么用?C# SourceRepository.GetPackageMetadataById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SourceRepository
的用法示例。
在下文中一共展示了SourceRepository.GetPackageMetadataById方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreatePackageSearchResult
private static async Task<JObject> CreatePackageSearchResult(SourceRepository source, IPackage package)
{
NuGetTraceSources.CoreInteropInstalledPackagesList.Verbose("loading_versions", "Loading versions for {0} from {1}", package.Id, source.Source.Url);
var versions = new List<SemanticVersion>();
var packages = await source.GetPackageMetadataById(package.Id);
foreach (var p in packages)
{
var v = SemanticVersion.Parse(p.Value<string>(Properties.Version));
versions.Add(v);
}
var result = PackageJsonLd.CreatePackageSearchResult(package, versions);
return result;
}
示例2: GetLatestVersionMetadata
// BUGBUG: Beware! Do not start piling up on this class to add more extension like methods
// This is temporary until we get a dedicated endpoint to get the latest version
internal static async Task<JObject> GetLatestVersionMetadata(SourceRepository sourceRepository, string packageId, bool prerelease)
{
var packages = await sourceRepository.GetPackageMetadataById(packageId);
JObject latestPackage = null;
NuGetVersion latestPackageVersion = null;
foreach(var package in packages)
{
var packageVersion = NuGetVersion.Parse(package["version"].ToString());
if (!prerelease && packageVersion.IsPrerelease)
continue;
if(latestPackageVersion == null || latestPackageVersion < packageVersion)
{
latestPackageVersion = packageVersion;
latestPackage = package;
}
}
return latestPackage;
}