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


C# Workspace.Shelve方法代码示例

本文整理汇总了C#中Microsoft.TeamFoundation.VersionControl.Client.Workspace.Shelve方法的典型用法代码示例。如果您正苦于以下问题:C# Workspace.Shelve方法的具体用法?C# Workspace.Shelve怎么用?C# Workspace.Shelve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.TeamFoundation.VersionControl.Client.Workspace的用法示例。


在下文中一共展示了Workspace.Shelve方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateShelveset

        /// <summary>
        /// 
        /// </summary>
        /// <param name="service"></param>
        /// <param name="workspace"></param>
        /// <param name="force">True when the user manually initiates a ShelveSet via the Team menu or mapped shortcut key.</param>
        private void CreateShelveset(VersionControlServer service, Workspace workspace, bool force)
        {
            // Build event args for notification create shelveset result
            var autoShelveEventArg = new ShelvesetCreatedEventArgs();

            try
            {
                // If there are no pending changes that have changed since the last shelveset then there is nothing to do
                bool isDelta = false;
                var pendingChanges = workspace.GetPendingChanges();
                int numPending = pendingChanges.Count();

                if (!force && numPending > 0)
                {
                    // Compare numPending to numItemsShelved;  Force shelveset if they differ
                    // Otherwise, resort to comparing file HashValues
                    var lastShelveset = GetPastShelvesets(service, workspace).FirstOrDefault();
                    var shelvedChanges = service.QueryShelvedChanges(lastShelveset)[0].PendingChanges;
                    int numItemsShelved = lastShelveset == null ? 0 : shelvedChanges.Count();
                    isDelta = (numPending != numItemsShelved) || pendingChanges.DifferFrom(shelvedChanges);
                }
                autoShelveEventArg.ShelvesetChangeCount = (force || isDelta) ? numPending : 0;
                if (force || isDelta)
                {
                    // Build a new, valid shelve set name
                    var setname = string.Format(ShelvesetName, workspace.Name, workspace.OwnerName, DateTime.Now, workspace.OwnerName.GetDomain(), workspace.OwnerName.GetLogin());
                    setname = CleanShelvesetName(setname);

                    // Actually create a new Shelveset 
                    var shelveset = new Shelveset(service, setname, workspace.OwnerName);
                    autoShelveEventArg.ShelvesetName = setname;
                    shelveset.Comment = string.Format("Shelved by {0}. {1} items", _extensionName, numPending);
                    workspace.Shelve(shelveset, pendingChanges, ShelvingOptions.Replace);

                    // Clean up past Shelvesets
                    if (MaximumShelvesets > 0)
                    {
                        foreach (var set in GetPastShelvesets(service, workspace).Skip(MaximumShelvesets))
                        {
                            service.DeleteShelveset(set);
                            autoShelveEventArg.ShelvesetsPurgeCount++;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _tfsExt = null; // Force re-init on next attempt
                autoShelveEventArg.ExecutionException = ex;
            }
            // Fire event for each VS instance to report results
            if (OnShelvesetCreated != null)
            {
                OnShelvesetCreated(this, autoShelveEventArg);
            }
        }
开发者ID:modulexcite,项目名称:tfsautoshelve,代码行数:62,代码来源:TfsAutoShelve.cs

示例2: WorkspaceShelve

 public void WorkspaceShelve(Workspace workspace, Shelveset shelveset, PendingChange[] pendingChanges, ShelvingOptions shelvingOptions)
 {
     workspace.Shelve(shelveset, pendingChanges, shelvingOptions);
 }
开发者ID:StanleyGoldman,项目名称:TeamPilgrim,代码行数:4,代码来源:TeamPilgrimTfsService.cs


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