本文整理汇总了C#中Dependency.RemovePossibleVersion方法的典型用法代码示例。如果您正苦于以下问题:C# Dependency.RemovePossibleVersion方法的具体用法?C# Dependency.RemovePossibleVersion怎么用?C# Dependency.RemovePossibleVersion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dependency
的用法示例。
在下文中一共展示了Dependency.RemovePossibleVersion方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestPossibleVersions
public void TestPossibleVersions()
{
Dependency dep = new Dependency("test", "artifact1", "2.0");
// adding multiple versions to a concrete version results in only that one.
dep.AddVersion("0.1");
Assert.False(dep.HasPossibleVersions);
dep.AddVersion("1.0");
dep.AddVersion("2.0.0");
dep.AddVersion("3.0");
Assert.True(dep.HasPossibleVersions);
Assert.True(dep.BestVersion == "2.0.0");
dep.RemovePossibleVersion(dep.BestVersion);
Assert.False(dep.HasPossibleVersions);
dep = new Dependency("test", "artifact1", "2.0+");
// check plus
dep.AddVersion("1.0");
dep.AddVersion("2.0.0");
dep.AddVersion("2.0.1");
dep.AddVersion("2.1");
dep.AddVersion("3.0");
Assert.True(dep.HasPossibleVersions);
Assert.True(dep.BestVersion == "2.1");
dep.RemovePossibleVersion(dep.BestVersion);
Assert.True(dep.BestVersion == "2.0.1");
dep.RemovePossibleVersion(dep.BestVersion);
Assert.True(dep.BestVersion == "2.0.0");
dep.RemovePossibleVersion(dep.BestVersion);
Assert.IsNullOrEmpty(dep.BestVersion);
Assert.False(dep.HasPossibleVersions);
dep = new Dependency("test", "artifact1", "2.0+");
// check plus
dep.AddVersion("3.0");
dep.AddVersion("2.2.0");
dep.AddVersion("2.0.1");
dep.AddVersion("2.1");
dep.AddVersion("1.0");
Assert.True(dep.HasPossibleVersions);
Assert.True(dep.BestVersion == "2.2.0");
dep.RemovePossibleVersion(dep.BestVersion);
Assert.True(dep.BestVersion == "2.1");
dep.RemovePossibleVersion(dep.BestVersion);
Assert.True(dep.BestVersion == "2.0.1");
dep.RemovePossibleVersion(dep.BestVersion);
Assert.IsNullOrEmpty(dep.BestVersion);
Assert.False(dep.HasPossibleVersions);
}
示例2: TestRefineVersionRange
public void TestRefineVersionRange()
{
Dependency dep = new Dependency("test", "artifact1", "2.0+");
dep.AddVersion("3.0");
dep.AddVersion("2.2.0");
dep.AddVersion("2.0.1");
dep.AddVersion("2.1");
dep.AddVersion("1.0");
// refinement with the same object should have no effect.
Assert.True(dep.RefineVersionRange(dep));
Assert.True(dep.HasPossibleVersions);
Assert.True(dep.BestVersion == "2.2.0");
dep.RemovePossibleVersion(dep.BestVersion);
Assert.True(dep.BestVersion == "2.1");
dep.RemovePossibleVersion(dep.BestVersion);
Assert.True(dep.BestVersion == "2.0.1");
dep.RemovePossibleVersion(dep.BestVersion);
Assert.IsNullOrEmpty(dep.BestVersion);
Assert.False(dep.HasPossibleVersions);
// refinement with a concrete version not compatible should fail.
dep = new Dependency("test", "artifact1", "2.0+");
dep.AddVersion("3.0");
dep.AddVersion("2.2.0");
dep.AddVersion("2.0.1");
dep.AddVersion("2.1");
dep.AddVersion("1.0");
Dependency dep1 = new Dependency("test", "artifact1", "3.0");
Assert.False(dep.RefineVersionRange(dep1));
Assert.False(dep.HasPossibleVersions);
// concrete included
dep = new Dependency("test", "artifact1", "2.0+");
dep.AddVersion("3.0");
dep.AddVersion("2.2.0");
dep.AddVersion("2.0.1");
dep.AddVersion("2.1");
dep.AddVersion("1.0");
Dependency dep2 = new Dependency("test", "artifact1", "2.1.0");
Assert.True(dep.RefineVersionRange(dep2));
Assert.True(dep.BestVersion == "2.1");
dep.RemovePossibleVersion(dep.BestVersion);
Assert.False(dep.HasPossibleVersions);
// check overlapping ranges
dep = new Dependency("test", "artifact1", "2.0+");
dep.AddVersion("3.0");
dep.AddVersion("2.2.0");
dep.AddVersion("2.0.1");
dep.AddVersion("2.1");
dep.AddVersion("1.0");
Dependency dep1plus = new Dependency("test", "artifact1", "2.1+");
Assert.True(dep.RefineVersionRange(dep1plus));
Assert.True(dep.BestVersion == "2.2.0");
dep.RemovePossibleVersion(dep.BestVersion);
Assert.True(dep.BestVersion == "2.1");
dep.RemovePossibleVersion(dep.BestVersion);
Assert.False(dep.HasPossibleVersions);
}
示例3: FindCandidate
/// <summary>
/// Finds an acceptable candidate for the given dependency.
/// </summary>
/// <returns>The dependency modified so BestVersion returns the best version.</returns>
/// <param name="repoPath">The path to the artifact repository.</param>
/// <param name="dep">The dependency to find a specific version for.</param>
internal Dependency FindCandidate(string repoPath, Dependency dep)
{
string basePath = Path.Combine(dep.Group, dep.Artifact);
basePath = basePath.Replace(".", Path.DirectorySeparatorChar.ToString());
string metadataFile = Path.Combine(Path.Combine(repoPath, basePath), "maven-metadata.xml");
if (File.Exists(metadataFile))
{
ProcessMetadata(dep, metadataFile);
dep.RepoPath = repoPath;
}
else
{
return null;
}
while (dep.HasPossibleVersions)
{
// TODO(wilkinsonclay): get the packaging from the pom.
// Check for the actual file existing, otherwise skip this version.
foreach (string ext in Packaging)
{
string basename = dep.Artifact + "-" + dep.BestVersion + ext;
string fname = Path.Combine(dep.BestVersionPath, basename);
if (File.Exists(fname))
{
return dep;
}
}
Log(dep.Key + " version " + dep.BestVersion + " not available, ignoring.",
verbose: true);
dep.RemovePossibleVersion(dep.BestVersion);
}
return null;
}