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 | |
---|---|---|
DepthFirstTreeComparer | This comparer can be used to sort version control paths depth-first, just like a tree traversal. | |
FullPathComparer | Returns a string comparer for fully-specified server paths. | |
StringComparer | This is a property for comparison of server paths in instances like a Dictionary hash. |
Top
Methods
Name | Description | |
---|---|---|
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. | |
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. | |
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. | |
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" | |
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") -&gt; @"$/blech" Combine(@"c:\myproj\abc\efg", @"c:\myproj\abc\efg\x", @"$/bar") -&gt; @"$/efg/x" Combine(@"c:\myproj\abc\efg", @"c:\yourproj\abc\efg\x", @"$/bar") -&gt; @"InvalidPathException" Combine(@"c:\myproj\abc\efg", @"c:\yourproj\abc\efg", @"$/myproj/abc/efg") -&gt; @"$/yourproj/abc/efg" | |
Compare(String, String) | Compares two version control item paths. | |
Compare(String, String, Int32, Int32) | Compares two version control item paths. | |
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. | |
CompareTopDown | Compares two Version Control paths and return their relative ordering. This is like Compare except that it sorts grandchildren after children. | |
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. | |
CompareUI(String, String) | Compares two Version Control item paths for display (culture-sensitive and case-insensitive). | |
CompareUI(String, String, Int32, Int32) | Compares two Version Control item paths for display (culture-sensitive and case-insensitive). | |
Equals | Compares two file specs for equality. | |
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. | |
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. | |
GetExtension | Gets the file name extension from a version control specification. | |
GetFileName | Returns the last path component from a canonicalized path. For example, passing "$/abc/xyz" would return "xyz". Passing "$/" will return "". | |
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. | |
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. | |
GetFolderName | Gets the parent folder for the specified canonicalized path. If "$/" is passed, "$/" is returned as the parent. | |
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. | |
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. | |
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. | |
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. | |
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 | |
GetTeamProject | Returns the top level "team project" folder given a server item. | |
GetTeamProjectName | Returns the top level "team project" given a server item. | |
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. | |
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. | |
IsImmediateChild | Returns true if item is an immediate child of parent. | |
IsRootFolder | ||
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. | |
IsSubItem | Returns true if the item is equal to or is under (in the heirarchy) parent. | |
IsTeamProject | Returns whether the passed server item is a team project ($/abc, $/def, not $/abc/efg nor $/) | |
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 | |
IsValidPath(String) | Returns true if path is valid; false otherwise. | |
IsValidPath(String, PathLength) | Returns true if path is valid; false otherwise | |
IsWildcard | Determines if the last component of the specified path contains a wildcard character. The path may be fully qualified. | |
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" | |
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" | |
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. | |
MatchFileName | Matches just the final component of the specified item to the specified wildcard. | |
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 "". | |
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. | |
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. | |
ValidatePath(String) | Validates the server path. Wildcards are not allowed. Exception is thrown if invalid. | |
ValidatePath(String, PathLength) | Validates the server path. Wildcards are not allowed Exception is thrown if invalid. |
Top
Fields
Name | Description | |
---|---|---|
RootFolder | ||
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.