本文整理汇总了C#中Microsoft.TeamFoundation.VersionControl.Client.Workspace.GetServerItemForLocalItem方法的典型用法代码示例。如果您正苦于以下问题:C# Workspace.GetServerItemForLocalItem方法的具体用法?C# Workspace.GetServerItemForLocalItem怎么用?C# Workspace.GetServerItemForLocalItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.TeamFoundation.VersionControl.Client.Workspace
的用法示例。
在下文中一共展示了Workspace.GetServerItemForLocalItem方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeleteFolder
/// <summary>
/// 'Pends' a delete of a folder and its contents that was previously
/// checked-in and then commits that deletion to the repository.
/// </summary>
/// <param name="workspace">Version control workspace to use when
/// deleting the folder and its contents.</param>
/// <param name="newFilename">Full path to the folder to delete</param>
/// <exception cref="SecurityException">If the user doesn't have
/// check-in permission for the specified <paramref name="workspace"/>.</exception>
/// <exception cref="IOException">If there's a problem creating the file.</exception>
/// <exception cref="VersionControlException">If </exception>
private static void DeleteFolder(Workspace workspace, String newFolder)
{
Debug.Assert(workspace != null);
Debug.Assert(!String.IsNullOrEmpty(newFolder));
try
{
// Delete the items
workspace.PendDelete(workspace.GetServerItemForLocalItem(newFolder), RecursionType.Full);
var pendingDeletes = workspace.GetPendingChanges();
if (pendingDeletes.Length > 0)
{
workspace.CheckIn(pendingDeletes, "Clean up!");
}
}
catch (VersionControlException ex)
{
Console.Error.WriteLine("Error deleting file: {0}", ex.Message);
throw;
}
}
示例2: ElPackager
public ElPackager(string root, TfsChangesets changesets)
{
_root = root;
var tpc = new TfsTeamProjectCollection(new Uri(TfsUrl));
var vc = tpc.GetService<VersionControlServer>();
_workspace = vc.GetWorkspace(root);
var serverFolder = _workspace.GetServerItemForLocalItem(root);
changesets.LoadChangesets(vc, serverFolder);
_changesets = changesets;
}
示例3: GetBranchNameForItem
public string GetBranchNameForItem(
string localFullPath,
bool waitForConnection,
CancellationToken cancellationToken,
out Workspace workspace,
out BranchObject branchObject)
{
workspace = null;
branchObject = null;
try
{
if (localFullPath.IsNullOrEmpty())
return null;
WaitForConnection();
if (cancellationToken.IsCancellationRequested)
return null;
var info = Workstation.Current.GetLocalWorkspaceInfo(localFullPath);
if (info == null)
return null;
var serverName = info.ServerUri;
var tfsSrv = Microsoft.TeamFoundation.Client.TeamFoundationServerFactory.GetServer(serverName);
VersionControlServer vcs = (VersionControlServer)tfsSrv.GetService(typeof(VersionControlServer));
if (cancellationToken.IsCancellationRequested)
return null;
workspace = vcs.TryGetWorkspace(localFullPath);
if (workspace == null)
return null;
var serverItem = workspace.GetServerItemForLocalItem(localFullPath);
if (cancellationToken.IsCancellationRequested)
return null;
var branchObjects =
vcs.QueryRootBranchObjects(RecursionType.Full)
.OrderBy(bo => bo.Properties.RootItem.Item)
.Reverse();
var itemSpecs = new ItemSpec[]
{
new ItemSpec(serverItem, RecursionType.None)
};
// for each itemSpec return BranchHistoryItem[]
var branchHistory = vcs.GetBranchHistory(itemSpecs, VersionSpec.Latest);
if (!branchHistory[0].Any())
return null;
if (cancellationToken.IsCancellationRequested)
return null;
branchObject =
(from bo in branchObjects
where serverItem.StartsWith(bo.Properties.RootItem.Item)
select bo).
FirstOrDefault();
if (branchObject == null)
return null;
var branchName = System.IO.Path.GetFileName(branchObject.Properties.RootItem.Item);
if (cancellationToken.IsCancellationRequested)
return null;
return branchName;
}
catch (Exception ex)
{
// TODO: logging
return null;
}
}
示例4: GetServerItemForLocalItem
public string GetServerItemForLocalItem(Workspace workspace, string localItem)
{
return workspace.GetServerItemForLocalItem(localItem);
}