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


C# ImmutableDictionary.Add方法代码示例

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


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

示例1: PrepareMetadata

 public ImmutableDictionary<string, object> PrepareMetadata(ImmutableDictionary<string, object> metadata)
 {
     if (!metadata.ContainsKey("_enableSearch"))
     {
         metadata = metadata.Add("_enableSearch", true);
     }
     return metadata;
 }
开发者ID:dotnet,项目名称:docfx,代码行数:8,代码来源:ExtractSearchIndex.cs

示例2: ImmutableDictionary_AddTest

 public void ImmutableDictionary_AddTest()
 {
     Dictionary<int, string> dictionary = new Dictionary<int, string>
     {
         {1,"asaas"},
         {2,"sasas"},
         {3,"tak"}
     };
     ImmutableDictionary<int, string> test = new ImmutableDictionary<int, string>(dictionary);
     test.Add(3, "dddfd");
 }
开发者ID:powermedia,项目名称:PowerMedia.Common,代码行数:11,代码来源:ImmutableCollectionsTests.cs

示例3: Create

        public static CompletionItem Create(
            string displayText,
            TextSpan span,
            Glyph? glyph = null,
            ImmutableArray<SymbolDisplayPart> description = default(ImmutableArray<SymbolDisplayPart>),
            string sortText = null,
            string filterText = null,
            bool preselect = false,
            bool showsWarningIcon = false,
            bool shouldFormatOnCommit = false,
            bool isArgumentName = false,
            ImmutableDictionary<string, string> properties = null,
            ImmutableArray<string> tags = default(ImmutableArray<string>),
            CompletionItemRules rules = null)
        {
            tags = tags.IsDefault ? ImmutableArray<string>.Empty : tags;

            if (glyph != null)
            {
                // put glyph tags first
                tags = GlyphTags.GetTags(glyph.Value).AddRange(tags);
            }

            if (showsWarningIcon)
            {
                tags = tags.Add(CompletionTags.Warning);
            }

            if (isArgumentName)
            {
                tags = tags.Add(CompletionTags.ArgumentName);
            }

            properties = properties ?? ImmutableDictionary<string, string>.Empty;
            if (!description.IsDefault && description.Length > 0)
            {
                properties = properties.Add("Description", EncodeDescription(description));
            }

            rules = rules ?? CompletionItemRules.Default;
            rules = rules.WithPreselect(preselect)
                         .WithFormatOnCommit(shouldFormatOnCommit);

            return CompletionItem.Create(
                displayText: displayText,
                filterText: filterText,
                sortText: sortText,
                span: span,
                properties: properties,
                tags: tags,
                rules: rules);
        }
开发者ID:RoryVL,项目名称:roslyn,代码行数:52,代码来源:CommonCompletionItem.cs

示例4: Create

        public static CompletionItem Create(
            string displayText,
            Glyph? glyph = null,
            ImmutableArray<SymbolDisplayPart> description = default(ImmutableArray<SymbolDisplayPart>),
            string sortText = null,
            string filterText = null,
            int? matchPriority = null,
            bool showsWarningIcon = false,
            bool shouldFormatOnCommit = false,
            ImmutableDictionary<string, string> properties = null,
            ImmutableArray<string> tags = default(ImmutableArray<string>),
            CompletionItemRules rules = null)
        {
            tags = tags.NullToEmpty();

            if (glyph != null)
            {
                // put glyph tags first
                tags = GlyphTags.GetTags(glyph.Value).AddRange(tags);
            }

            if (showsWarningIcon)
            {
                tags = tags.Add(CompletionTags.Warning);
            }

            properties = properties ?? ImmutableDictionary<string, string>.Empty;
            if (!description.IsDefault && description.Length > 0)
            {
                properties = properties.Add("Description", EncodeDescription(description));
            }

            rules = rules ?? CompletionItemRules.Default;
            rules = rules.WithMatchPriority(matchPriority.GetValueOrDefault())
                         .WithFormatOnCommit(shouldFormatOnCommit);

            return CompletionItem.Create(
                displayText: displayText,
                filterText: filterText,
                sortText: sortText,
                properties: properties,
                tags: tags,
                rules: rules);
        }
开发者ID:jkotas,项目名称:roslyn,代码行数:44,代码来源:CommonCompletionItem.cs

示例5: TryAddImport

        private static bool TryAddImport(
            string alias,
            NamespaceOrTypeSymbol targetSymbol,
            ArrayBuilder<NamespaceOrTypeAndUsingDirective> usingsBuilder,
            ImmutableDictionary<string, AliasAndUsingDirective>.Builder usingAliases,
            InContainerBinder binder,
            ImportRecord importRecord)
        {
            if (alias == null)
            {
                usingsBuilder.Add(new NamespaceOrTypeAndUsingDirective(targetSymbol, usingDirective: null));
            }
            else
            {
                IdentifierNameSyntax aliasSyntax;
                if (!TryParseIdentifierNameSyntax(alias, out aliasSyntax))
                {
                    Debug.WriteLine($"Import record '{importRecord}' has syntactically invalid alias '{alias}'");
                    return false;
                }

                var aliasSymbol = AliasSymbol.CreateCustomDebugInfoAlias(targetSymbol, aliasSyntax.Identifier, binder);
                usingAliases.Add(alias, new AliasAndUsingDirective(aliasSymbol, usingDirective: null));
            }

            return true;
        }
开发者ID:rgani,项目名称:roslyn,代码行数:27,代码来源:CompilationContext.cs

示例6: AddStringFormatMap

            private static void AddStringFormatMap(ImmutableDictionary<IMethodSymbol, Info>.Builder builder, INamedTypeSymbol type, string methodName)
            {
                if (type == null)
                {
                    return;
                }

                foreach (IMethodSymbol method in type.GetMembers(methodName).OfType<IMethodSymbol>())
                {
                    int formatIndex = FindParameterIndexOfName(method.Parameters, Format);
                    if (formatIndex < 0 || formatIndex == method.Parameters.Length - 1)
                    {
                        // no valid format string
                        continue;
                    }

                    int expectedArguments = GetExpectedNumberOfArguments(method.Parameters, formatIndex);
                    builder.Add(method, new Info(formatIndex, expectedArguments));
                }
            }
开发者ID:duracellko,项目名称:roslyn-analyzers,代码行数:20,代码来源:ProvideCorrectArgumentsToFormattingMethods.cs

示例7: AddDiagnosticForSymbolIfNeeded

            private static void AddDiagnosticForSymbolIfNeeded(ISymbol targetSymbol, Diagnostic diagnostic, ImmutableDictionary<ISymbol, List<Diagnostic>>.Builder diagnosticsMapBuilder)
            {
                if (diagnostic.IsSuppressed)
                {
                    return;
                }

                if (!diagnosticsMapBuilder.TryGetValue(targetSymbol, out var diagnosticsForSymbol))
                {
                    diagnosticsForSymbol = new List<Diagnostic>();
                    diagnosticsMapBuilder.Add(targetSymbol, diagnosticsForSymbol);
                }

                diagnosticsForSymbol.Add(diagnostic);
            }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:15,代码来源:AbstractSuppressionCodeFixProvider.GlobalSuppressMessageFixAllCodeAction.cs

示例8: AddSolutionProperties

 private ImmutableDictionary<string, string> AddSolutionProperties(ImmutableDictionary<string, string> properties, string solutionFilePath)
 {
     // http://referencesource.microsoft.com/#MSBuildFiles/C/ProgramFiles(x86)/MSBuild/14.0/bin_/amd64/Microsoft.Common.CurrentVersion.targets,296
     properties = properties ?? ImmutableDictionary<string, string>.Empty;
     properties = properties.Add("SolutionName", Path.GetFileNameWithoutExtension(solutionFilePath));
     properties = properties.Add("SolutionFileName", Path.GetFileName(solutionFilePath));
     properties = properties.Add("SolutionPath", solutionFilePath);
     properties = properties.Add("SolutionDir", Path.GetDirectoryName(solutionFilePath));
     properties = properties.Add("SolutionExt", Path.GetExtension(solutionFilePath));
     return properties;
 }
开发者ID:akrisiun,项目名称:SourceBrowser,代码行数:11,代码来源:SolutionGenerator.cs

示例9: CreateWorkspace

        private static MSBuildWorkspace CreateWorkspace(ImmutableDictionary<string, string> propertiesOpt = null)
        {
            propertiesOpt = propertiesOpt ?? ImmutableDictionary<string, string>.Empty;

            // Explicitly add "CheckForSystemRuntimeDependency = true" property to correctly resolve facade references.
            // See https://github.com/dotnet/roslyn/issues/560
            propertiesOpt = propertiesOpt.Add("CheckForSystemRuntimeDependency", "true");
            propertiesOpt = propertiesOpt.Add("VisualStudioVersion", "14.0");

            try
            {
                Microsoft.CodeAnalysis.Host.HostServices hostServices = WorkspaceHacks.Pack;
                return MSBuildWorkspace.Create(properties: propertiesOpt, hostServices: hostServices);
            } catch {}

            return MSBuildWorkspace.Create(properties: propertiesOpt);
        }
开发者ID:akrisiun,项目名称:SourceBrowser,代码行数:17,代码来源:SolutionGenerator.cs

示例10: Remove_Test

 public void Remove_Test()
 {
 	Dictionary<int, string> _dictionary = new Dictionary<int, string>
     {
         {1, "aabb"},
         {2, "bbcc"},
         {3, "ccdd"}
     };
 	ImmutableDictionary<int, string> _immutableDictionary = new ImmutableDictionary<int, string>(_dictionary);
 	_immutableDictionary.Add(new KeyValuePair<int, string>(4, "ddee"));
 }
开发者ID:powermedia,项目名称:PowerMedia.Common,代码行数:11,代码来源:ImmutableCollectionsTests.cs

示例11: CreateWorkspace

        private static MSBuildWorkspace CreateWorkspace(ImmutableDictionary<string, string> propertiesOpt = null)
        {
            propertiesOpt = propertiesOpt ?? ImmutableDictionary<string, string>.Empty;

            // Explicitly add "CheckForSystemRuntimeDependency = true" property to correctly resolve facade references.
            // See https://github.com/dotnet/roslyn/issues/560
            propertiesOpt = propertiesOpt.Add("CheckForSystemRuntimeDependency", "true");
            propertiesOpt = propertiesOpt.Add("VisualStudioVersion", "14.0");

            var w = MSBuildWorkspace.Create(properties: propertiesOpt, hostServices: WorkspaceHacks.Pack);
            w.LoadMetadataForReferencedProjects = true;
            return w;
        }
开发者ID:KirillOsenkov,项目名称:SourceBrowser,代码行数:13,代码来源:SolutionGenerator.cs

示例12: MergeProjectDiagnosticAnalyzerDiagnosticsAsync

            private async Task<ImmutableDictionary<DiagnosticAnalyzer, AnalysisResult>> MergeProjectDiagnosticAnalyzerDiagnosticsAsync(
                Project project, IEnumerable<StateSet> stateSets, Compilation compilationOpt, ImmutableDictionary<DiagnosticAnalyzer, AnalysisResult> result, CancellationToken cancellationToken)
            {
                // check whether there is IDE specific project diagnostic analyzer
                var ideAnalyzers = stateSets.Select(s => s.Analyzer).Where(a => a is ProjectDiagnosticAnalyzer || a is DocumentDiagnosticAnalyzer).ToImmutableArrayOrEmpty();
                if (ideAnalyzers.Length <= 0)
                {
                    return result;
                }

                // create result map
                var version = await GetDiagnosticVersionAsync(project, cancellationToken).ConfigureAwait(false);
                var builder = new CompilerDiagnosticExecutor.Builder(project, version);

                foreach (var analyzer in ideAnalyzers)
                {
                    var documentAnalyzer = analyzer as DocumentDiagnosticAnalyzer;
                    if (documentAnalyzer != null)
                    {
                        foreach (var document in project.Documents)
                        {
                            if (document.SupportsSyntaxTree)
                            {
                                var tree = await document.GetSyntaxTreeAsync(cancellationToken).ConfigureAwait(false);
                                builder.AddSyntaxDiagnostics(tree, await ComputeDocumentDiagnosticAnalyzerDiagnosticsAsync(document, documentAnalyzer, AnalysisKind.Syntax, compilationOpt, cancellationToken).ConfigureAwait(false));
                                builder.AddSemanticDiagnostics(tree, await ComputeDocumentDiagnosticAnalyzerDiagnosticsAsync(document, documentAnalyzer, AnalysisKind.Semantic, compilationOpt, cancellationToken).ConfigureAwait(false));
                            }
                            else
                            {
                                builder.AddExternalSyntaxDiagnostics(document.Id, await ComputeDocumentDiagnosticAnalyzerDiagnosticsAsync(document, documentAnalyzer, AnalysisKind.Syntax, compilationOpt, cancellationToken).ConfigureAwait(false));
                                builder.AddExternalSemanticDiagnostics(document.Id, await ComputeDocumentDiagnosticAnalyzerDiagnosticsAsync(document, documentAnalyzer, AnalysisKind.Semantic, compilationOpt, cancellationToken).ConfigureAwait(false));
                            }
                        }
                    }

                    var projectAnalyzer = analyzer as ProjectDiagnosticAnalyzer;
                    if (projectAnalyzer != null)
                    {
                        builder.AddCompilationDiagnostics(await ComputeProjectDiagnosticAnalyzerDiagnosticsAsync(project, projectAnalyzer, compilationOpt, cancellationToken).ConfigureAwait(false));
                    }

                    // merge the result to existing one.
                    result = result.Add(analyzer, builder.ToResult());
                }

                return result;
            }
开发者ID:RoryVL,项目名称:roslyn,代码行数:47,代码来源:DiagnosticIncrementalAnalyzer.Executor.cs


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