本文整理汇总了C#中SemanticVersion.GetComparableVersionStrings方法的典型用法代码示例。如果您正苦于以下问题:C# SemanticVersion.GetComparableVersionStrings方法的具体用法?C# SemanticVersion.GetComparableVersionStrings怎么用?C# SemanticVersion.GetComparableVersionStrings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SemanticVersion
的用法示例。
在下文中一共展示了SemanticVersion.GetComparableVersionStrings方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Exists
public override bool Exists(string packageId, SemanticVersion version)
{
if (version != null)
{
// optimization: if we find the .nuspec file at "id.version"\"id.version".nuspec or
// the .nupkg file at "id.version"\"id.version".nupkg, consider it exists
bool hasPackageDirectory = version.GetComparableVersionStrings()
.Select(v => packageId + "." + v)
.Any(path => FileSystem.FileExists(Path.Combine(path, path + Constants.PackageExtension)) ||
FileSystem.FileExists(Path.Combine(path, path + Constants.ManifestExtension)));
if (hasPackageDirectory)
{
return true;
}
}
return FindPackage(packageId, version) != null;
}
示例2: FindPackage
public IPackage FindPackage(string packageId, SemanticVersion version)
{
IQueryable<DataServicePackage> query = Context.CreateQuery<DataServicePackage>(PackageServiceEntitySetName).AsQueryable();
foreach (string versionString in version.GetComparableVersionStrings())
{
try
{
var packages = query.Where(p => p.Id == packageId && p.Version == versionString).ToArray();
Debug.Assert(packages == null || packages.Length <= 1);
if (packages.Length != 0)
{
return packages[0];
}
}
catch (DataServiceQueryException)
{
// DataServiceQuery exception will occur when the (id, version)
// combination doesn't exist.
}
}
return null;
}
示例3: FindPackage
/// <summary>
/// Find-Package
/// </summary>
/// <param name="packageId">package Id</param>
/// <param name="version">package version</param>
/// <param name="request"></param>
/// <returns></returns>
public IPackage FindPackage(string packageId, SemanticVersion version, NuGetRequest request)
{
if (string.IsNullOrWhiteSpace(packageId)) {
return null;
}
request.Debug(Messages.DebugInfoCallMethod3, "HttpClientPackageRepository", "FindPackage", packageId);
var query = packageId.MakeFindPackageByIdQuery(_nugetFindPackageIdQueryFormat);
var packages = NuGetClient.FindPackage(query, request);
//Usually versions has a limited number, ToArray should be ok.
var versions = version.GetComparableVersionStrings().ToArray();
//Will only enumerate packages once
return packages.FirstOrDefault(package => packageId.Equals(package.Id, StringComparison.OrdinalIgnoreCase) && versions.Contains(package.Version,StringComparer.OrdinalIgnoreCase));
}
示例4: Exists
public bool Exists(string packageId, SemanticVersion version)
{
IQueryable<DataServicePackage> query = Context.CreateQuery<DataServicePackage>(PackageServiceEntitySetName).AsQueryable();
foreach (string versionString in version.GetComparableVersionStrings())
{
try
{
var packages = query.Where(p => p.Id == packageId && p.Version == versionString)
.Select(p => p.Id) // since we only want to check for existence, no need to get all attributes
.ToArray();
if (packages.Length == 1)
{
return true;
}
}
catch (DataServiceQueryException)
{
// DataServiceQuery exception will occur when the (id, version)
// combination doesn't exist.
}
}
return false;
}