当前位置: 首页>>代码示例>>C#>>正文


C# Workspace.GetServerItemForLocalItem方法代码示例

本文整理汇总了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;
            }
        }
开发者ID:spraints,项目名称:svn2tfs,代码行数:33,代码来源:Program.cs

示例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;
 }
开发者ID:kocubinski,项目名称:TfsPackage,代码行数:10,代码来源:ElPackager.cs

示例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;
            }
        }
开发者ID:gandarez,项目名称:VSCommands,代码行数:84,代码来源:TeamFoundationHelper.cs

示例4: GetServerItemForLocalItem

 public string GetServerItemForLocalItem(Workspace workspace, string localItem)
 {
     return workspace.GetServerItemForLocalItem(localItem);
 }
开发者ID:vardars,项目名称:ci-factory,代码行数:4,代码来源:TfsVersionControlFunctions.cs


注:本文中的Microsoft.TeamFoundation.VersionControl.Client.Workspace.GetServerItemForLocalItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。