다음을 통해 공유


VersionControlPath Class

A utility class for manipulating version control items specifications. It contains routines for parsing, formatting, validating, and so on.

Inheritance Hierarchy

System.Object
  Microsoft.TeamFoundation.VersionControl.Common.VersionControlPath

Namespace:  Microsoft.TeamFoundation.VersionControl.Common
Assembly:  Microsoft.TeamFoundation.VersionControl.Common (in Microsoft.TeamFoundation.VersionControl.Common.dll)

Syntax

'Declaration
Public NotInheritable Class VersionControlPath
public static class VersionControlPath
public ref class VersionControlPath abstract sealed
[<AbstractClass>]
[<Sealed>]
type VersionControlPath =  class end
public final class VersionControlPath

The VersionControlPath type exposes the following members.

Properties

  Name Description
Public propertyStatic member DepthFirstTreeComparer This comparer can be used to sort version control paths depth-first, just like a tree traversal.
Public propertyStatic member FullPathComparer Returns a string comparer for fully-specified server paths.
Public propertyStatic member StringComparer This is a property for comparison of server paths in instances like a Dictionary hash.

Top

Methods

  Name Description
Public methodStatic member CheckForIllegalDollarInPath This method throws an InvalidPathException if there is a dollar sign ('$') that follows a path separator ('/'), because no part of a path can start with a dollar sign.
Public methodStatic member Combine(String, String) Returns a fully qualified and canonicalized path constructed from parent and relative. If relative is already a fully qualified path, just return a canonicalized copy of relative. If relative is not fully qualified, return the path that results from appending relative to parent and canonicalizing the result. It is assumed that parent is already canonicalized.
Public methodStatic member Combine(String, String, PathLength) Returns a fully qualified and canonicalized path constructed from parent and relative. If relative is already a fully qualified path, just return a canonicalized copy of relative. If relative is not fully qualified, return the path that results from appending relative to parent and canonicalizing the result. It is assumed that parent is already canonicalized.
Public methodStatic member Combine(String, String, String) Given a base local path, base server path and target local path computes the target server path. This is completed by generating the relative path for the local paths, converting that to a server relative path and combining it with the base server path. Note: This method will throw an invalid path exception if it cannot generate the target server path. Possible reasons for this include the following: 1) local paths are on different drives and are not relative. 2) combining the calculated relative path with the base server path causes a "negative folder depth" (that is directory above root, $/). Examples: Combine(@"c:\myproj\abc\xyz", @"c:\myproj\abc\blech", @"$/abc") -> @"$/blech" Combine(@"c:\myproj\abc\xyz", @"c:\myproj\abc\xyz\x", @"$/xyz") -> @"$/xyz/x" Combine(@"c:\myproj\abc\xyz", @"c:\yourproj\abc\xyz\x", @"$/xyz") -> @"InvalidPathException" Combine(@"c:\myproj\abc\xyz", @"c:\yourproj\abc\xyz", @"$/myproj/abc/xyz") -> @"$/yourproj/abc/xyz"
Public methodStatic member Combine(String, String, String, PathLength) Given a base local path, base server path and target local path computes the target server path. This is done by generating the relative path for the local paths, converting that to a server relative path and combining it with the base server path. Note: This method will throw an invalid path exception if it cannot generate the target server path. Possible reasons for this include: 1) local paths are on different drives and are not relative. 2) combining the calculated relative path with the base server path results in a "negative folder depth" (i.e. directory above root, $/). Examples: Combine(@"c:\myproj\abc\efg", @"c:\myproj\abc\blech", @"$/foo") -&amp;gt; @"$/blech" Combine(@"c:\myproj\abc\efg", @"c:\myproj\abc\efg\x", @"$/bar") -&amp;gt; @"$/efg/x" Combine(@"c:\myproj\abc\efg", @"c:\yourproj\abc\efg\x", @"$/bar") -&amp;gt; @"InvalidPathException" Combine(@"c:\myproj\abc\efg", @"c:\yourproj\abc\efg", @"$/myproj/abc/efg") -&amp;gt; @"$/yourproj/abc/efg"
Public methodStatic member Compare(String, String) Compares two version control item paths.
Public methodStatic member Compare(String, String, Int32, Int32) Compares two version control item paths.
Public methodStatic member CompareCaseSensitive Compares two Version Control item paths in a case-insensitive manner on every part of the path except for the last item in the path. The last item in the path is compared in a case-sensitive manner.
Public methodStatic member CompareTopDown Compares two Version Control paths and return their relative ordering. This is like Compare except that it sorts grandchildren after children.
Public methodStatic member CompareTopDownUI Compares two Version Control paths and returns their relative ordering for display (culture and case insensitive). This is like Compare except that it sorts grandchildren after children.
Public methodStatic member CompareUI(String, String) Compares two Version Control item paths for display (culture-sensitive and case-insensitive).
Public methodStatic member CompareUI(String, String, Int32, Int32) Compares two Version Control item paths for display (culture-sensitive and case-insensitive).
Public methodStatic member Equals Compares two file specs for equality.
Public methodStatic member EqualsCaseSensitive Checks two file paths for equality. Returns whether they are equal in a case-insensitive manner on every part of the path except for the last item in the path. The last item in the path is compared in a case-sensitive manner.
Public methodStatic member GetCommonParent Given two server paths, returns the farthest item from $/ that parents both items. If one of the two paths is null, the other will be returned. If both paths are null, an ArgumentNullException is thrown.
Public methodStatic member GetExtension Gets the file name extension from a version control specification.
Public methodStatic member GetFileName Returns the last path component from a canonicalized path. For example, passing "$/abc/xyz" would return "xyz". Passing "$/" will return "".
Public methodStatic member GetFolderDepth(String) Returns the number of levels of path elements in this specification.$/ will return 0 $/abc will return 1 $/abc/xyz will return 2, and so on.
Public methodStatic member GetFolderDepth(String, Int32) Returns the number of levels of path elements in this specification up to the maximum depth.$/ will return 0 $/abc will return 1 $/abc/xyz will return 2, and so on.
Public methodStatic member GetFolderName Gets the parent folder for the specified canonicalized path. If "$/" is passed, "$/" is returned as the parent.
Public methodStatic member GetFullPath(String) Canonicalizes the specified items specification and return the string. This will do things such as remove ..'s, convert \ to /, and so on. It throws an InvalidPathException if the item is the empty string, contains invalid characters including an embedded dollar sign (wildcard characters are not considered invalid in this check), or is too long.
Public methodStatic member GetFullPath(String, PathLength) Canonicalizes the specified items specification and return the string. This will do things like remove ..'s, convert \ to /, etc. It throws an InvalidPathException if the item is the empty string, contains invalid characters including an embedded dollar sign (wildcards are not considered illegal in this check), or is too long.
Public methodStatic member GetFullPath(String, Boolean) Canonicalizes the specified items specification and return the string. This will do things such as remove ..'s, convert \ to /, and so on. It throws an InvalidPathException if the item is the empty string, contains invalid characters including an embedded dollar sign (wildcard characters are not considered invalid in this check), or is too long.
Public methodStatic member GetFullPath(String, Boolean, PathLength) Canonicalizes the specified items specification and return the string. This will do things like remove ..'s, convert \ to /, etc. It throws an InvalidPathException if the item is the empty string, contains invalid characters including an embedded dollar sign (wildcards are not considered illegal in this check), or is too long.
Public methodStatic member GetRelativeStartIndex Given a path and folder, returns the index of the substring in path relative to the folder. If the path is not under the folder then 0 is returned (meaning the entire path). MakeRelative(@"$/src/project/abc.cpp", @"$/src") -> 6 MakeRelative(@"$/src/project/abc.cpp", @"$/specs") -> 0 MakeRelative(@"$/src/project/abc.cpp", @"$/src/proj") -> 0
Public methodStatic member GetTeamProject Returns the top level "team project" folder given a server item.
Public methodStatic member GetTeamProjectName Returns the top level "team project" given a server item.
Public methodStatic member IsCanonicalizedPath(String, Boolean) Returns true if the path is canonicalized. The path must not contain a $ at the start of a path part, or any invalid characters.
Public methodStatic member IsCanonicalizedPath(String, Boolean, PathLength) Returns true if the path is canonicalized. The path must not contain a $ at the beginning of a path part, or any illegal characters.
Public methodStatic member IsImmediateChild Returns true if item is an immediate child of parent.
Public methodStatic member IsRootFolder
Public methodStatic member IsServerItem Returns true if the specified string appears to be a server item (instead of a local item). The path is not required to be canonicalized. All server item paths are absolute.
Public methodStatic member IsSubItem Returns true if the item is equal to or is under (in the heirarchy) parent.
Public methodStatic member IsTeamProject Returns whether the passed server item is a team project ($/abc, $/def, not $/abc/efg nor $/)
Public methodStatic member IsValidFolderName Checks if the specified folder name is valid. By folder name, we are referring to a single folder, not the full path. Wild cards are not allowed here. For example, a folder name in the full path below could be A, B, or C $/A/B/C/file.txt
Public methodStatic member IsValidPath(String) Returns true if path is valid; false otherwise.
Public methodStatic member IsValidPath(String, PathLength) Returns true if path is valid; false otherwise
Public methodStatic member IsWildcard Determines if the last component of the specified path contains a wildcard character. The path may be fully qualified.
Public methodStatic member MakeRelative(String, String) Given a path and folder, returns the path relative to the folder. If the path is not under the folder the path is returned unmodified. Both path and folder are assumed to be in canonical form. Examples: MakeRelative(@"$/src/project/abc.cpp", @"$/src") -> @"project/abc.cpp" MakeRelative(@"$/src/project/abc.cpp", @"$/specs") -> @"$/src/project/abc.cpp" MakeRelative(@"$/src/project/abc.cpp", @"$/src/proj") -> @"$/src/project/abc.cpp"
Public methodStatic member MakeRelative(String, String, Boolean) Given a path and folder, returns the path relative to the folder. If the path is not under the folder and the recursive parameter is false then path is returned unmodified. Otherwise, the method iteratively each parent directory in the specified folder and tries to make item relative. Both path and folder are assumed to be in canonical form. Examples: MakeRelative(@"$/src/project/abc.cpp", @"$/src",false) -> @"project/abc.cpp" MakeRelative(@"$/src/project/abc.cpp", @"$/specs",false) -> @"$/src/project/abc.cpp" MakeRelative(@"$/src/project/abc.cpp", @"$/src/proj",false) -> @"$/src/project/abc.cpp" MakeRelative(@"$/src/project/abc.cpp", @"$/src", true) -> @"project/abc.cpp" MakeRelative(@"$/src/project/abc.cpp", @"$/specs", true) -> @"../src/project/abc.cpp" MakeRelative(@"$/src/project/abc.cpp", @"$/src/proj", true) -> @"../project/abc.cpp"
Public methodStatic member Match Compares an item to see whether it matches a folder and a name that may be a wildcard. If recursive is true then any matching item under the matchFolder will match. Wildcard matching is performed by using the NT file system matching rules.
Public methodStatic member MatchFileName Matches just the final component of the specified item to the specified wildcard.
Public methodStatic member Parse Parses a canonicalized item specification into a parent folder and the last path component. If "$/" is passed, the parent is "$/" and the name is "".
Public methodStatic member PrependRootIfNeeded(String) Utility method to prepend the root ($/) to a folder - most useful for getting the folder of a team project if you only have his name.
Public methodStatic member PrependRootIfNeeded(String, PathLength) Utility method to prepend the root ($/) to a folder - most useful for getting the folder of a team project if you only have his name.
Public methodStatic member ValidatePath(String) Validates the server path. Wildcards are not allowed. Exception is thrown if invalid.
Public methodStatic member ValidatePath(String, PathLength) Validates the server path. Wildcards are not allowed Exception is thrown if invalid.

Top

Fields

  Name Description
Public fieldStatic member RootFolder
Public fieldStatic member Separator

Top

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

Microsoft.TeamFoundation.VersionControl.Common Namespace