• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ImmutableDictionary类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Solution

        private Solution(
            BranchId branchId,
            int workspaceVersion,
            SolutionServices solutionServices,
            SolutionId id,
            string filePath,
            ImmutableList<ProjectId> projectIds,
            ImmutableDictionary<ProjectId, ProjectState> idToProjectStateMap,
            ImmutableDictionary<ProjectId, CompilationTracker> projectIdToTrackerMap,
            ProjectDependencyGraph dependencyGraph,
            VersionStamp version,
            Lazy<VersionStamp> lazyLatestProjectVersion)
        {
            this.branchId = branchId;
            this.workspaceVersion = workspaceVersion;
            this.id = id;
            this.filePath = filePath;
            this.solutionServices = solutionServices;
            this.projectIds = projectIds;
            this.projectIdToProjectStateMap = idToProjectStateMap;
            this.projectIdToTrackerMap = projectIdToTrackerMap;
            this.dependencyGraph = dependencyGraph;
            this.projectIdToProjectMap = ImmutableHashMap<ProjectId, Project>.Empty;
            this.version = version;
            this.lazyLatestProjectVersion = lazyLatestProjectVersion;

            CheckInvariants();
        }
开发者ID:riversky,项目名称:roslyn,代码行数:28,代码来源:Solution.cs


示例2: FilterModel

            public void FilterModel(
                CompletionFilterReason filterReason,
                bool recheckCaretPosition = false,
                bool dismissIfEmptyAllowed = true,
                ImmutableDictionary<CompletionItemFilter, bool> filterState = null)
            {
                AssertIsForeground();

                var caretPosition = GetCaretPointInViewBuffer();

                // Use an interlocked increment so that reads by existing filter tasks will see the
                // change.
                Interlocked.Increment(ref _filterId);
                var localId = _filterId;
                Computation.ChainTaskAndNotifyControllerWhenFinished(
                    model =>
                    {
                        if (model != null && filterState != null)
                        {
                            // If the UI specified an updated filter state, then incorporate that 
                            // into our model.
                            model = model.WithFilterState(filterState);
                        }

                        return FilterModelInBackground(
                            model, localId, caretPosition, recheckCaretPosition, dismissIfEmptyAllowed, filterReason);
                    });
            }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:28,代码来源:Controller.Session_FilterModel.cs


示例3: ChangeDependencies

        /// <summary>
        /// Change the NuGet dependencies in the file to match the new packages.
        /// </summary>
        internal static bool ChangeDependencies(string filePath, ImmutableDictionary<NuGetPackage, NuGetPackage> changeMap)
        {
            var obj = JObject.Parse(File.ReadAllText(filePath), new JsonLoadSettings() { CommentHandling = CommentHandling.Load });
            var dependencies = (JObject)obj["dependencies"];
            if (dependencies == null)
            {
                return false;
            }

            var changed = false;
            foreach (var prop in dependencies.Properties())
            {
                var currentPackage = ParseDependency(prop);
                NuGetPackage newPackage;
                if (!changeMap.TryGetValue(currentPackage, out newPackage))
                {
                    continue;
                }

                ChangeDependency(prop, newPackage.Version);
                changed = true;
            }

            if (!changed)
            {
                return false;
            }

            var data = JsonConvert.SerializeObject(obj, Formatting.Indented);
            File.WriteAllText(filePath, data);
            return true;
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:35,代码来源:ProjectJsonUtil.cs


示例4: SolutionState

        private SolutionState(
            BranchId branchId,
            int workspaceVersion,
            SolutionServices solutionServices,
            SolutionId id,
            string filePath,
            IEnumerable<ProjectId> projectIds,
            ImmutableDictionary<ProjectId, ProjectState> idToProjectStateMap,
            ImmutableDictionary<ProjectId, CompilationTracker> projectIdToTrackerMap,
            ImmutableDictionary<string, ImmutableArray<DocumentId>> linkedFilesMap,
            ProjectDependencyGraph dependencyGraph,
            VersionStamp version,
            Lazy<VersionStamp> lazyLatestProjectVersion)
        {
            _branchId = branchId;
            _workspaceVersion = workspaceVersion;
            _id = id;
            _filePath = filePath;
            _solutionServices = solutionServices;
            _projectIds = projectIds.ToImmutableReadOnlyListOrEmpty();
            _projectIdToProjectStateMap = idToProjectStateMap;
            _projectIdToTrackerMap = projectIdToTrackerMap;
            _linkedFilesMap = linkedFilesMap;
            _dependencyGraph = dependencyGraph;
            _version = version;
            _lazyLatestProjectVersion = lazyLatestProjectVersion;

            CheckInvariants();
        }
开发者ID:tvsonar,项目名称:roslyn,代码行数:29,代码来源:SolutionState.cs


示例5: SimpleDiagnostic

            private SimpleDiagnostic(
                DiagnosticDescriptor descriptor,
                DiagnosticSeverity severity,
                int warningLevel,
                Location location,
                IEnumerable<Location> additionalLocations,
                object[] messageArgs,
                ImmutableDictionary<string, string> properties,
                bool isSuppressed)
            {
                if ((warningLevel == 0 && severity != DiagnosticSeverity.Error) ||
                    (warningLevel != 0 && severity == DiagnosticSeverity.Error))
                {
                    throw new ArgumentException(nameof(warningLevel));
                }

                if (descriptor == null)
                {
                    throw new ArgumentNullException(nameof(descriptor));
                }

                _descriptor = descriptor;
                _severity = severity;
                _warningLevel = warningLevel;
                _location = location ?? Location.None;
                _additionalLocations = additionalLocations?.ToImmutableArray() ?? SpecializedCollections.EmptyReadOnlyList<Location>();
                _messageArgs = messageArgs ?? Array.Empty<object>();
                _properties = properties ?? ImmutableDictionary<string, string>.Empty;
                _isSuppressed = isSuppressed;
            }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:30,代码来源:Diagnostic_SimpleDiagnostic.cs


示例6: GetFixAsync

        internal sealed override async Task<CodeAction> GetFixAsync(
            ImmutableDictionary<Document, ImmutableArray<Diagnostic>> documentsAndDiagnosticsToFixMap, 
            FixAllState fixAllState, 
            CancellationToken cancellationToken)
        {
            // Process all documents in parallel.
            var updatedDocumentTasks = documentsAndDiagnosticsToFixMap.Select(
                kvp => FixDocumentAsync(kvp.Key, kvp.Value, cancellationToken));

            await Task.WhenAll(updatedDocumentTasks).ConfigureAwait(false);

            var currentSolution = fixAllState.Solution;
            foreach (var task in updatedDocumentTasks)
            {
                // 'await' the tasks so that if any completed in a cancelled manner then we'll
                // throw the right exception here.  Calling .Result on the tasks might end up
                // with AggregateExceptions being thrown instead.
                var updatedDocument = await task.ConfigureAwait(false);
                currentSolution = currentSolution.WithDocumentSyntaxRoot(
                    updatedDocument.Id,
                    await updatedDocument.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false));
            }

            var title = fixAllState.GetDefaultFixAllTitle();
            return new CodeAction.SolutionChangeAction(title, _ => Task.FromResult(currentSolution));
        }
开发者ID:jkotas,项目名称:roslyn,代码行数:26,代码来源:DocumentBasedFixAllProvider.cs


示例7: MSBuildWorkspace

 private MSBuildWorkspace(
     HostServices hostServices,
     ImmutableDictionary<string, string> properties)
     : base(hostServices, "MSBuildWorkspace")
 {
     _loader = new MSBuildProjectLoader(this, properties);
 }
开发者ID:noahstein,项目名称:roslyn,代码行数:7,代码来源:MSBuildWorkspace.cs


示例8: TestNetwork

 public TestNetwork() {
   _message = String.Empty;
   _address = String.Empty;
   _fingerprint = String.Empty;
   _addresses = ImmutableDictionary<string, string>.Empty;
   _fingerprints = ImmutableDictionary<string, string>.Empty;
 }
开发者ID:pstjuste,项目名称:brunet,代码行数:7,代码来源:TestNetwork.cs


示例9: Load

        public override FileModel Load(FileAndType file, ImmutableDictionary<string, object> metadata)
        {
            if (file.Type != DocumentType.Article)
            {
                throw new NotSupportedException();
            }
            var content = MarkdownReader.ReadMarkdownAsConceptual(file.BaseDir, file.File);
            foreach (var item in metadata)
            {
                if (!content.ContainsKey(item.Key))
                {
                    content[item.Key] = item.Value;
                }
            }

            var displayLocalPath = PathUtility.MakeRelativePath(EnvironmentContext.BaseDirectory, file.FullPath);

            return new FileModel(
                file,
                content,
                serializer: Environment.Is64BitProcess ? null : new BinaryFormatter())
            {
                LocalPathFromRepoRoot = (content["source"] as SourceDetail)?.Remote?.RelativePath,
                LocalPathFromRoot = displayLocalPath
            };
        }
开发者ID:vicancy,项目名称:docfx,代码行数:26,代码来源:ConceptualDocumentProcessor.cs


示例10: GetFixAsync

        public virtual async Task<CodeAction> GetFixAsync(
            ImmutableDictionary<Document, ImmutableArray<Diagnostic>> documentsAndDiagnosticsToFixMap,
            FixAllContext fixAllContext)
        {
            if (documentsAndDiagnosticsToFixMap != null && documentsAndDiagnosticsToFixMap.Any())
            {
                FixAllLogger.LogDiagnosticsStats(documentsAndDiagnosticsToFixMap);

                var fixesBag = new ConcurrentBag<CodeAction>();

                using (Logger.LogBlock(FunctionId.CodeFixes_FixAllOccurrencesComputation_Fixes, fixAllContext.CancellationToken))
                {
                    fixAllContext.CancellationToken.ThrowIfCancellationRequested();

                    var documents = documentsAndDiagnosticsToFixMap.Keys;
                    var tasks = documents.Select(d => AddDocumentFixesAsync(d, documentsAndDiagnosticsToFixMap[d], fixesBag.Add, fixAllContext))
                                         .ToArray();
                    await Task.WhenAll(tasks).ConfigureAwait(false);
                }

                if (fixesBag.Any())
                {
                    using (Logger.LogBlock(FunctionId.CodeFixes_FixAllOccurrencesComputation_Merge, fixAllContext.CancellationToken))
                    {
                        FixAllLogger.LogFixesToMergeStats(fixesBag);
                        return await TryGetMergedFixAsync(fixesBag, fixAllContext).ConfigureAwait(false);
                    }
                }
            }

            return null;
        }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:32,代码来源:BatchFixAllProvider.cs


示例11: ImmutableSentenceDomainModel

 public ImmutableSentenceDomainModel(ISentenceFormModel formModel, IDictionary<ISentenceForm, ISentenceFormDomain> domains)
     : base(ImmutableSentenceFormModel.CopyOf(formModel))
 {
     //if (!formModel.SentenceForms.SetEquals(domains.Keys))
     //    throw new Exception();
     _domains = domains.ToImmutableDictionary();
 }
开发者ID:druzil,项目名称:nggp-base,代码行数:7,代码来源:ImmutableSentenceDomainModel.cs


示例12: MemoryStorageManager

        internal MemoryStorageManager(ChainedHeader chainTip = null, int? unspentTxCount = null, int? unspentOutputCount = null, int? totalTxCount = null, int? totalInputCount = null, int? totalOutputCount = null, ImmutableSortedDictionary<UInt256, ChainedHeader> headers = null, ImmutableSortedDictionary<UInt256, UnspentTx> unspentTransactions = null, ImmutableDictionary<int, BlockSpentTxes> spentTransactions = null)
        {
            blockStorage = new MemoryBlockStorage();
            blockTxesStorage = new MemoryBlockTxesStorage();
            chainStateStorage = new MemoryChainStateStorage(chainTip, unspentTxCount, unspentOutputCount, totalTxCount, totalInputCount, totalOutputCount, headers, unspentTransactions, spentTransactions);
            unconfirmedTxesStorage = new MemoryUnconfirmedTxesStorage();

            chainStateCursorCache = new DisposableCache<IChainStateCursor>(1024,
                createFunc: () => new MemoryChainStateCursor(chainStateStorage),
                prepareAction: cursor =>
                {
                    // rollback any open transaction before returning the cursor to the cache
                    if (cursor.InTransaction)
                        cursor.RollbackTransaction();
                });

            unconfirmedTxesCursorCache = new DisposableCache<IUnconfirmedTxesCursor>(1024,
                createFunc: () => new MemoryUnconfirmedTxesCursor(unconfirmedTxesStorage),
                prepareAction: cursor =>
                {
                    // rollback any open transaction before returning the cursor to the cache
                    if (cursor.InTransaction)
                        cursor.RollbackTransaction();
                });
        }
开发者ID:cole2295,项目名称:BitSharp,代码行数:25,代码来源:MemoryStorageManager.cs


示例13: SolutionState

        private SolutionState(
            BranchId branchId,
            int workspaceVersion,
            SolutionServices solutionServices,
            SolutionInfo solutionInfo,
            IEnumerable<ProjectId> projectIds,
            ImmutableDictionary<ProjectId, ProjectState> idToProjectStateMap,
            ImmutableDictionary<ProjectId, CompilationTracker> projectIdToTrackerMap,
            ImmutableDictionary<string, ImmutableArray<DocumentId>> linkedFilesMap,
            ProjectDependencyGraph dependencyGraph,
            Lazy<VersionStamp> lazyLatestProjectVersion)
        {
            _branchId = branchId;
            _workspaceVersion = workspaceVersion;
            _solutionServices = solutionServices;
            _solutionInfo = solutionInfo;
            _projectIds = projectIds.ToImmutableReadOnlyListOrEmpty();
            _projectIdToProjectStateMap = idToProjectStateMap;
            _projectIdToTrackerMap = projectIdToTrackerMap;
            _linkedFilesMap = linkedFilesMap;
            _dependencyGraph = dependencyGraph;
            _lazyLatestProjectVersion = lazyLatestProjectVersion;

            // when solution state is changed, we re-calcuate its checksum
            _lazyChecksums = new AsyncLazy<SolutionStateChecksums>(ComputeChecksumsAsync, cacheResult: true);

            CheckInvariants();
        }
开发者ID:TyOverby,项目名称:roslyn,代码行数:28,代码来源:SolutionState.cs


示例14: CompilerAnalysisResult

 public CompilerAnalysisResult(
     ImmutableDictionary<DiagnosticAnalyzer, AnalysisResult> analysisResult,
     ImmutableDictionary<DiagnosticAnalyzer, AnalyzerTelemetryInfo> telemetryInfo)
 {
     AnalysisResult = analysisResult;
     TelemetryInfo = telemetryInfo;
 }
开发者ID:RoryVL,项目名称:roslyn,代码行数:7,代码来源:CompilerAnalysisResult.cs


示例15: GetFixAsync

        public virtual async Task<CodeAction> GetFixAsync(
            ImmutableDictionary<Document, ImmutableArray<Diagnostic>> documentsAndDiagnosticsToFixMap,
            FixAllContext fixAllContext)
        {
            if (documentsAndDiagnosticsToFixMap != null && documentsAndDiagnosticsToFixMap.Any())
            {
                FixAllLogger.LogDiagnosticsStats(documentsAndDiagnosticsToFixMap);

                var fixesBag = new ConcurrentBag<CodeAction>();

                using (Logger.LogBlock(FunctionId.CodeFixes_FixAllOccurrencesComputation_Fixes, fixAllContext.CancellationToken))
                {
                    fixAllContext.CancellationToken.ThrowIfCancellationRequested();

                    var documents = documentsAndDiagnosticsToFixMap.Keys.ToImmutableArray();
                    var options = new ParallelOptions() { CancellationToken = fixAllContext.CancellationToken };
                    Parallel.ForEach(documents, options, document =>
                    {
                        fixAllContext.CancellationToken.ThrowIfCancellationRequested();
                        AddDocumentFixesAsync(document, documentsAndDiagnosticsToFixMap[document], fixesBag.Add, fixAllContext).Wait(fixAllContext.CancellationToken);
                    });
                }

                if (fixesBag.Any())
                {
                    using (Logger.LogBlock(FunctionId.CodeFixes_FixAllOccurrencesComputation_Merge, fixAllContext.CancellationToken))
                    {
                        FixAllLogger.LogFixesToMergeStats(fixesBag);
                        return await TryGetMergedFixAsync(fixesBag, fixAllContext).ConfigureAwait(false);
                    }
                }
            }

            return null;
        }
开发者ID:nileshjagtap,项目名称:roslyn,代码行数:35,代码来源:BatchFixAllProvider.cs


示例16: ProjectDependencyGraph

 internal ProjectDependencyGraph(
     ImmutableList<ProjectId> projectIds,
     ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> referencesMap)
 {
     this.projectIds = projectIds;
     this.referencesMap = referencesMap;
 }
开发者ID:riversky,项目名称:roslyn,代码行数:7,代码来源:ProjectDependencyGraph.cs


示例17: ProjectState

        internal ProjectState(ProjectInfo projectInfo, HostLanguageServices languageServices, SolutionServices solutionServices)
        {
            Contract.ThrowIfNull(projectInfo);
            Contract.ThrowIfNull(languageServices);
            Contract.ThrowIfNull(solutionServices);

            _languageServices = languageServices;
            _solutionServices = solutionServices;

            _projectInfo = FixProjectInfo(projectInfo);

            _documentIds = _projectInfo.Documents.Select(d => d.Id).ToImmutableArray();
            _additionalDocumentIds = this.ProjectInfo.AdditionalDocuments.Select(d => d.Id).ToImmutableArray();

            var docStates = ImmutableDictionary.CreateRange<DocumentId, DocumentState>(
                _projectInfo.Documents.Select(d =>
                    new KeyValuePair<DocumentId, DocumentState>(d.Id,
                        CreateDocument(this.ProjectInfo, d, languageServices, solutionServices))));

            _documentStates = docStates;

            var additionalDocStates = ImmutableDictionary.CreateRange<DocumentId, TextDocumentState>(
                    _projectInfo.AdditionalDocuments.Select(d =>
                        new KeyValuePair<DocumentId, TextDocumentState>(d.Id, TextDocumentState.Create(d, solutionServices))));

            _additionalDocumentStates = additionalDocStates;

            _lazyLatestDocumentVersion = new AsyncLazy<VersionStamp>(c => ComputeLatestDocumentVersionAsync(docStates, additionalDocStates, c), cacheResult: true);
            _lazyLatestDocumentTopLevelChangeVersion = new AsyncLazy<VersionStamp>(c => ComputeLatestDocumentTopLevelChangeVersionAsync(docStates, additionalDocStates, c), cacheResult: true);
        }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:30,代码来源:ProjectState.cs


示例18: RuleSet

 /// <summary>
 /// Create a RuleSet.
 /// </summary>
 public RuleSet(string filePath, ReportDiagnostic generalOption, ImmutableDictionary<string, ReportDiagnostic> specificOptions, ImmutableArray<RuleSetInclude> includes)
 {
     _filePath = filePath;
     _generalDiagnosticOption = generalOption;
     _specificDiagnosticOptions = specificOptions == null ? ImmutableDictionary<string, ReportDiagnostic>.Empty : specificOptions;
     _includes = includes.IsDefault ? ImmutableArray<RuleSetInclude>.Empty : includes;
 }
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:10,代码来源:RuleSet.cs


示例19: ParseResult

 public ParseResult(string input, string output, int? position, ImmutableDictionary<string, ImmutableArray<TextSpan>> spanMap)
 {
     this.input = input;
     this.output = output;
     this.position = position;
     this.spanMap = spanMap;
 }
开发者ID:modulexcite,项目名称:StylishCode,代码行数:7,代码来源:MarkupCode.ParseResult.cs


示例20: ProjectDependencyGraph

 internal ProjectDependencyGraph(
     ImmutableArray<ProjectId> projectIds,
     ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> referencesMap)
 {
     _projectIds = projectIds;
     _referencesMap = referencesMap;
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:7,代码来源:ProjectDependencyGraph.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ImmutableHashSet类代码示例发布时间:2022-05-24
下一篇:
C# ImmutableArray类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap