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


C# Workspace.TryApplyChanges方法代码示例

本文整理汇总了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);
        }
开发者ID:TyOverby,项目名称:roslyn,代码行数:13,代码来源:RenameDocumentOperation.cs

示例2: Apply

 public override void Apply(Workspace workspace, CancellationToken cancellationToken)
 {
     workspace.TryApplyChanges(_changedSolution);
 }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:4,代码来源:ApplyChangesOperation.cs

示例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);
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:5,代码来源:ApplyChangesOperation.cs

示例6: TryApply

 internal override bool TryApply(
     Workspace workspace, IProgressTracker progressTracker, CancellationToken cancellationToken)
 {
     workspace.TryApplyChanges(ChangedSolution, progressTracker);
     return true;
 }
开发者ID:jkotas,项目名称:roslyn,代码行数:6,代码来源:ApplyChangesOperation.cs


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