本文整理汇总了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);
}
}
示例2: WorkspaceShelve
public void WorkspaceShelve(Workspace workspace, Shelveset shelveset, PendingChange[] pendingChanges, ShelvingOptions shelvingOptions)
{
workspace.Shelve(shelveset, pendingChanges, shelvingOptions);
}