本文整理汇总了C#中RelativePath.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# RelativePath.ToString方法的具体用法?C# RelativePath.ToString怎么用?C# RelativePath.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RelativePath
的用法示例。
在下文中一共展示了RelativePath.ToString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestPaths
public void TestPaths()
{
FullPath root;
FullPath full;
RelativePath rel;
string str1, str2;
string[,] cases =
{
// root: // full: // full canonical: // relative canonical:
{ @"C:\a/b/c/", @"D:\a/b/", @"D:\a\b\", @"D:\a\b\" },
{ @"C:\a\b\c", @"C:\a\b\c", @"C:\a\b\c", @"" },
{ @"C:\a\b\c", @"C:\a\b\c\", @"C:\a\b\c\", @"" },
{ @"C:\a\b\c\", @"C:\a\b\c", @"C:\a\b\c", @"" },
{ @"C:\a\b\c\", @"C:\a\b\c\", @"C:\a\b\c\", @"" },
{ @"C:\a\b\c", @"C:\a\b", @"C:\a\b", @".." },
{ @"C:\a\b\c\", @"C:\a\b", @"C:\a\b", @".." },
{ @"C:\a\b\c", @"C:\", @"C:\", @"..\..\.." },
{ @"C:\a\b\c\", @"C:\", @"C:\", @"..\..\.." },
{ @"C:\a\b\c\", @"C:\a\b\x\y\z", @"C:\a\b\x\y\z", @"..\x\y\z" },
{ @"C:\a\b\cd\", @"C:\a\b\c", @"C:\a\b\c", @"..\c" },
{ @"C:\a\b\cd", @"C:\a\b\c", @"C:\a\b\c", @"..\c" },
{ @"C:\a\b\cd\", @"C:\a\b\c\d", @"C:\a\b\c\d", @"..\c\d" },
{ @"C:\a\b\cd", @"C:\a\b\c\d", @"C:\a\b\c\d", @"..\c\d" },
};
for (int i = 0; i < cases.GetLength(0); i++)
{
root = new FullPath(cases[i, 0]);
full = new FullPath(cases[i, 1]);
rel = new RelativePath(root, full);
Assert.AreEqual(full.ToString(), cases[i, 2]);
Assert.AreEqual(rel.ToString(), cases[i, 3]);
str1 = full;
if (str1[str1.Length - 1] == '\\') str1 = str1.Substring(0, str1.Length - 1);
str2 = rel.ToFullPath(root);
if (str2[str2.Length - 1] == '\\') str2 = str2.Substring(0, str2.Length - 1);
Assert.AreEqual(str1, str2);
Assert.AreEqual(RelativePath.ParseCanonical(cases[i, 3]).ToString(), cases[i, 3]);
}
}
示例2: RelativePath_Unit_ToString_RelativePathhasEmptyLastNode
public void RelativePath_Unit_ToString_RelativePathhasEmptyLastNode()
{
String[] nodes = new String[] { "sites", "Chad", "Greer", String.Empty };
Char separator = RelativePath.ForwardSlash;
RelativePath target = new RelativePath(nodes, separator);
String actual = target.ToString();
Assert.AreEqual(nodes.Join(separator), actual);
}
示例3: RelativePath_Unit_ImplicitStringCastOperator_Optimal
public void RelativePath_Unit_ImplicitStringCastOperator_Optimal()
{
String[] nodes = new String[] { "sites", "Chad", "Greer" };
Char separator = RelativePath.ForwardSlash;
RelativePath instance = new RelativePath(nodes, separator);
String actual = instance;
Assert.AreEqual(instance.ToString(), actual);
}