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


C# ImmutableArray.Single方法代码示例

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


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

示例1: GetDebuggerBrowsableState

 private static DebuggerBrowsableState GetDebuggerBrowsableState(ImmutableArray<SynthesizedAttributeData> attributes)
 {
     return (DebuggerBrowsableState)attributes.Single(a => a.AttributeClass.Name == "DebuggerBrowsableAttribute").ConstructorArguments.First().Value;
 }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:4,代码来源:AttributeTests_Synthesized.cs

示例2: PublicAttributed

		public void PublicAttributed( ImmutableArray<Type> types )
		{
			Assert.Single( types );
			Assert.Equal( "DragonSpark.Testing.Parts.PublicClass", types.Single().FullName );
		}
开发者ID:DevelopersWin,项目名称:VoteReporter,代码行数:5,代码来源:PartsTests.cs

示例3: CheckCustomModifier

 /// <summary>
 /// True - assert that the list contains a single const modifier.
 /// False - assert that the list is empty.
 /// </summary>
 private static void CheckCustomModifier(bool expectCustomModifier, ImmutableArray<CustomModifier> customModifiers)
 {
     if (expectCustomModifier)
     {
         Assert.Equal(ConstModOptType, customModifiers.Single().Modifier.ToTestDisplayString());
     }
     else
     {
         Assert.False(customModifiers.Any());
     }
 }
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:15,代码来源:CustomModifierCopyTests.cs

示例4: ApplyAsync

        public async Task ApplyAsync(
            Workspace workspace, Document fromDocument,
            ImmutableArray<CodeActionOperation> operations,
            string title, IProgressTracker progressTracker,
            CancellationToken cancellationToken)
        {
            this.AssertIsForeground();

            if (operations.IsDefaultOrEmpty)
            {
                return;
            }

            if (_renameService.ActiveSession != null)
            {
                workspace.Services.GetService<INotificationService>()?.SendNotification(
                    EditorFeaturesResources.Cannot_apply_operation_while_a_rename_session_is_active,
                    severity: NotificationSeverity.Error);
                return;
            }

#if DEBUG
            var documentErrorLookup = new HashSet<DocumentId>();
            foreach (var project in workspace.CurrentSolution.Projects)
            {
                foreach (var document in project.Documents)
                {
                    // ConfigureAwait(true) so we come back to the same thread as 
                    // we do all application on the UI thread.                    
                    if (!await document.HasAnyErrorsAsync(cancellationToken).ConfigureAwait(true))
                    {
                        documentErrorLookup.Add(document.Id);
                    }
                }
            }
#endif

            var oldSolution = workspace.CurrentSolution;

            // Determine if we're making a simple text edit to a single file or not.
            // If we're not, then we need to make a linked global undo to wrap the 
            // application of these operations.  This way we should be able to undo 
            // them all with one user action.
            //
            // The reason we don't always create a gobal undo is that a global undo
            // forces all files to save.  And that's rather a heavyweight and 
            // unexpected experience for users (for the common case where a single 
            // file got edited).
            var singleChangedDocument = TryGetSingleChangedText(oldSolution, operations);
            if (singleChangedDocument != null)
            {
                // ConfigureAwait(true) so we come back to the same thread as 
                // we do all application on the UI thread.
                var text = await singleChangedDocument.GetTextAsync(cancellationToken).ConfigureAwait(true);

                using (workspace.Services.GetService<ISourceTextUndoService>().RegisterUndoTransaction(text, title))
                {
                    operations.Single().Apply(workspace, cancellationToken);
                }
            }
            else
            {
                // More than just a single document changed.  Make a global undo to run 
                // all the changes under.
                using (var transaction = workspace.OpenGlobalUndoTransaction(title))
                {
                    // ConfigureAwait(true) so we come back to the same thread as 
                    // we do all application on the UI thread.
                    ProcessOperations(
                        workspace, operations, progressTracker,
                        cancellationToken);

                    // link current file in the global undo transaction
                    if (fromDocument != null)
                    {
                        transaction.AddDocument(fromDocument.Id);
                    }

                    transaction.Commit();
                }
            }

#if DEBUG
            foreach (var project in workspace.CurrentSolution.Projects)
            {
                foreach (var document in project.Documents)
                {
                    if (documentErrorLookup.Contains(document.Id))
                    {
                        document.VerifyNoErrorsAsync("CodeAction introduced error in error-free code", cancellationToken).Wait(cancellationToken);
                    }
                }
            }
#endif

            var updatedSolution = operations.OfType<ApplyChangesOperation>().FirstOrDefault()?.ChangedSolution ?? oldSolution;
            TryStartRenameSession(workspace, oldSolution, updatedSolution, cancellationToken);
        }
开发者ID:jkotas,项目名称:roslyn,代码行数:98,代码来源:CodeActionEditHandlerService.cs

示例5: TryGetSingleChangedText

        private TextDocument TryGetSingleChangedText(
            Solution oldSolution, ImmutableArray<CodeActionOperation> operationsList)
        {
            Debug.Assert(operationsList.Length > 0);
            if (operationsList.Length > 1)
            {
                return null;
            }

            var applyOperation = operationsList.Single() as ApplyChangesOperation;
            if (applyOperation == null)
            {
                return null;
            }

            var newSolution = applyOperation.ChangedSolution;
            var changes = newSolution.GetChanges(oldSolution);

            if (changes.GetAddedProjects().Any() ||
                changes.GetRemovedProjects().Any())
            {
                return null;
            }

            var projectChanges = changes.GetProjectChanges().ToImmutableArray();
            if (projectChanges.Length != 1)
            {
                return null;
            }

            var projectChange = projectChanges.Single();
            if (projectChange.GetAddedAdditionalDocuments().Any() ||
                projectChange.GetAddedAnalyzerReferences().Any() ||
                projectChange.GetAddedDocuments().Any() ||
                projectChange.GetAddedMetadataReferences().Any() ||
                projectChange.GetAddedProjectReferences().Any() ||
                projectChange.GetRemovedAdditionalDocuments().Any() ||
                projectChange.GetRemovedAnalyzerReferences().Any() ||
                projectChange.GetRemovedDocuments().Any() ||
                projectChange.GetRemovedMetadataReferences().Any() ||
                projectChange.GetRemovedProjectReferences().Any())
            {
                return null;
            }

            var changedAdditionalDocuments = projectChange.GetChangedAdditionalDocuments().ToImmutableArray();
            var changedDocuments = projectChange.GetChangedDocuments().ToImmutableArray();

            if (changedAdditionalDocuments.Length + changedDocuments.Length != 1)
            {
                return null;
            }

            return changedDocuments.Length == 1
                ? oldSolution.GetDocument(changedDocuments[0])
                : oldSolution.GetAdditionalDocument(changedAdditionalDocuments[0]);
        }
开发者ID:jkotas,项目名称:roslyn,代码行数:57,代码来源:CodeActionEditHandlerService.cs

示例6: CompletionChange

 private CompletionChange(ImmutableArray<TextChange> textChanges, int? newPosition, bool includesCommitCharacter)
     : this(textChanges.Single(), newPosition, includesCommitCharacter)
 {
 }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:4,代码来源:CompletionChange.cs


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