本文整理汇总了C#中ImmutableDictionary类的典型用法代码示例。如果您正苦于以下问题:C# ImmutableDictionary类的具体用法?C# ImmutableDictionary怎么用?C# ImmutableDictionary使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ImmutableDictionary类属于命名空间,在下文中一共展示了ImmutableDictionary类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例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);
});
}
示例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;
}
示例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();
}
示例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;
}
示例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));
}
示例7: MSBuildWorkspace
private MSBuildWorkspace(
HostServices hostServices,
ImmutableDictionary<string, string> properties)
: base(hostServices, "MSBuildWorkspace")
{
_loader = new MSBuildProjectLoader(this, properties);
}
示例8: TestNetwork
public TestNetwork() {
_message = String.Empty;
_address = String.Empty;
_fingerprint = String.Empty;
_addresses = ImmutableDictionary<string, string>.Empty;
_fingerprints = ImmutableDictionary<string, string>.Empty;
}
示例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
};
}
示例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;
}
示例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();
}
示例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();
});
}
示例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();
}
示例14: CompilerAnalysisResult
public CompilerAnalysisResult(
ImmutableDictionary<DiagnosticAnalyzer, AnalysisResult> analysisResult,
ImmutableDictionary<DiagnosticAnalyzer, AnalyzerTelemetryInfo> telemetryInfo)
{
AnalysisResult = analysisResult;
TelemetryInfo = telemetryInfo;
}
示例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;
}