本文整理汇总了C#中Workspace.TryApplyChanges方法的典型用法代码示例。如果您正苦于以下问题:C# Workspace.TryApplyChanges方法的具体用法?C# Workspace.TryApplyChanges怎么用?C# Workspace.TryApplyChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Workspace
的用法示例。
在下文中一共展示了Workspace.TryApplyChanges方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryApply
internal override bool TryApply(Workspace workspace, IProgressTracker progressTracker, CancellationToken cancellationToken)
{
var solution = workspace.CurrentSolution;
// currently, document rename is accomplished by a remove followed by an add.
// the workspace takes care of resolving conflicts if the document name is not unique in the project
// by adding numeric suffixes to the new document being added.
var oldDocument = solution.GetDocument(_oldDocumentId);
var newSolution = solution.RemoveDocument(_oldDocumentId);
newSolution = newSolution.AddDocument(_newDocumentId, _newFileName, _text, oldDocument.Folders);
return workspace.TryApplyChanges(newSolution, progressTracker);
}
示例2: Apply
public override void Apply(Workspace workspace, CancellationToken cancellationToken)
{
workspace.TryApplyChanges(_changedSolution);
}
示例3: UpdateWorkspaceForGlobalIdentifierRename
private void UpdateWorkspaceForGlobalIdentifierRename(
Workspace workspace,
Solution newSolution,
Solution oldSolution,
string undoName,
IEnumerable<DocumentId> changedDocuments,
ISymbol symbol,
string newName,
int trackingSessionId)
{
AssertIsForeground();
// Perform rename in a workspace undo action so that undo will revert all
// references. It should also be performed in an ITextUndoTransaction to handle
var undoHistory = _undoHistoryRegistry.RegisterHistory(_stateMachine.Buffer);
using (var workspaceUndoTransaction = workspace.OpenGlobalUndoTransaction(undoName))
using (var localUndoTransaction = undoHistory.CreateTransaction(undoName))
{
var undoPrimitiveBefore = new UndoPrimitive(_stateMachine.Buffer, trackingSessionId, shouldRestoreStateOnUndo: false);
localUndoTransaction.AddUndo(undoPrimitiveBefore);
if (!workspace.TryApplyChanges(newSolution))
{
Contract.Fail("Rename Tracking could not update solution.");
}
if (!_refactorNotifyServices.TryOnAfterGlobalSymbolRenamed(workspace, changedDocuments, symbol, newName, throwOnFailure: false))
{
var notificationService = workspace.Services.GetService<INotificationService>();
notificationService.SendNotification(
EditorFeaturesResources.RenameOperationWasNotProperlyCompleted,
EditorFeaturesResources.RenameSymbol,
NotificationSeverity.Information);
}
// Never resume tracking session on redo
var undoPrimitiveAfter = new UndoPrimitive(_stateMachine.Buffer, trackingSessionId, shouldRestoreStateOnUndo: false);
localUndoTransaction.AddUndo(undoPrimitiveAfter);
localUndoTransaction.Complete();
workspaceUndoTransaction.Commit();
}
}
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:45,代码来源:RenameTrackingTaggerProvider.RenameTrackingCommitter.cs
示例4: UpdateWorkspaceForResetOfTypedIdentifier
private void UpdateWorkspaceForResetOfTypedIdentifier(Workspace workspace, Solution newSolution, int trackingSessionId)
{
AssertIsForeground();
// Update document in an ITextUndoTransaction with custom behaviors on undo/redo to
// deal with the state machine.
var undoHistory = _undoHistoryRegistry.RegisterHistory(_stateMachine.Buffer);
using (var localUndoTransaction = undoHistory.CreateTransaction(EditorFeaturesResources.TextBufferChange))
{
var undoPrimitiveBefore = new UndoPrimitive(_stateMachine.Buffer, trackingSessionId, shouldRestoreStateOnUndo: true);
localUndoTransaction.AddUndo(undoPrimitiveBefore);
if (!workspace.TryApplyChanges(newSolution))
{
Contract.Fail("Rename Tracking could not update solution.");
}
// Never resume tracking session on redo
var undoPrimitiveAfter = new UndoPrimitive(_stateMachine.Buffer, trackingSessionId, shouldRestoreStateOnUndo: false);
localUndoTransaction.AddUndo(undoPrimitiveAfter);
localUndoTransaction.Complete();
}
}
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:25,代码来源:RenameTrackingTaggerProvider.RenameTrackingCommitter.cs
示例5: Apply
internal override void Apply(
Workspace workspace, IProgressTracker progressTracker, CancellationToken cancellationToken)
{
workspace.TryApplyChanges(_changedSolution, progressTracker);
}
示例6: TryApply
internal override bool TryApply(
Workspace workspace, IProgressTracker progressTracker, CancellationToken cancellationToken)
{
workspace.TryApplyChanges(ChangedSolution, progressTracker);
return true;
}