本文整理汇总了C#中ImmutableDictionary.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# ImmutableDictionary.Remove方法的具体用法?C# ImmutableDictionary.Remove怎么用?C# ImmutableDictionary.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImmutableDictionary
的用法示例。
在下文中一共展示了ImmutableDictionary.Remove方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ImmutableDictionary_RemoveTest
public void ImmutableDictionary_RemoveTest()
{
Dictionary<int, string> dictionary = new Dictionary<int, string>
{
{1,"asaas"},
{2,"sasas"},
{3,"tak"}
};
ImmutableDictionary<int, string> test = new ImmutableDictionary<int, string>(dictionary);
test.Remove(2);
}
示例2: DiagnosticAnalyzerMap
public DiagnosticAnalyzerMap(HostAnalyzerManager analyzerManager, string language, ImmutableDictionary<DiagnosticAnalyzer, StateSet> analyzerMap)
{
// hold directly on to compiler analyzer
_compilerAnalyzer = analyzerManager.GetCompilerDiagnosticAnalyzer(language);
// in test case, we might not have the compiler analyzer.
if (_compilerAnalyzer == null)
{
_map = analyzerMap;
return;
}
_compilerStateSet = analyzerMap[_compilerAnalyzer];
// hold rest of analyzers
_map = analyzerMap.Remove(_compilerAnalyzer);
}
示例3: RemoveSyntaxTreeFromDeclarationMapAndTable
private static void RemoveSyntaxTreeFromDeclarationMapAndTable(
SyntaxTree tree,
ref ImmutableDictionary<SyntaxTree, Lazy<RootSingleNamespaceDeclaration>> declMap,
ref DeclarationTable declTable,
ref bool referenceDirectivesChanged)
{
Lazy<RootSingleNamespaceDeclaration> lazyRoot;
if (!declMap.TryGetValue(tree, out lazyRoot))
{
throw new ArgumentException(string.Format(CSharpResources.SyntaxTreeNotFoundTo, tree), "trees");
}
declTable = declTable.RemoveRootDeclaration(lazyRoot);
declMap = declMap.Remove(tree);
referenceDirectivesChanged = referenceDirectivesChanged || tree.HasReferenceDirectives();
}
示例4: RemoveOldTreeFromMap
private static ImmutableDictionary<DocumentId, SyntaxTree> RemoveOldTreeFromMap(
Compilation newCompilation,
ImmutableDictionary<DocumentId, SyntaxTree> oldMap, ImmutableDictionary<DocumentId, SyntaxTree> map,
CancellationToken cancellationToken)
{
foreach (var oldIdAndTree in oldMap)
{
cancellationToken.ThrowIfCancellationRequested();
// check whether new compilation still has the tree
if (newCompilation.ContainsSyntaxTree(oldIdAndTree.Value))
{
continue;
}
var documentId = oldIdAndTree.Key;
// check whether the tree has been updated
SyntaxTree currentTree;
if (!map.TryGetValue(documentId, out currentTree) ||
currentTree != oldIdAndTree.Value)
{
continue;
}
// this has been removed
map = map.Remove(documentId);
}
return map;
}
示例5: ParseDocumentAsync
private void ParseDocumentAsync(Document document)
{
var cancellationTokenSource = new CancellationTokenSource();
using (_stateLock.DisposableWrite())
{
_workMap = _workMap.Add(document.Id, cancellationTokenSource);
}
var cancellationToken = cancellationTokenSource.Token;
var task = _taskScheduler.ScheduleTask(
() => document.GetSyntaxTreeAsync(cancellationToken),
"BackgroundParser.ParseDocumentAsync",
cancellationToken);
// Always ensure that we mark this work as done from the workmap.
task.SafeContinueWith(
_ =>
{
using (_stateLock.DisposableWrite())
{
_workMap = _workMap.Remove(document.Id);
}
}, CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.Default);
}
示例6: Add_Test
public void Add_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.Remove(new KeyValuePair<int, string>(1, "aabb"));
}
示例7: RemoveCandidateIfParamDefault
private ImmutableDictionary<String, ParameterSet> RemoveCandidateIfParamDefault(
ImmutableDictionary<String, ParameterSet> candidates,
Parameter parameter
)
{
if (parameter.IsCommonParameter)
{
Logger.Debug(
"Skipping common parameter {Parameter}",
parameter.Name
);
return candidates;
}
if (parameter.HasDefaultValue(Target))
{
Logger.Debug(
"Parameter {Parameter} has default value, removing {ParameterSetName} from candidates",
parameter.Name,
parameter.ParameterSetName
);
return candidates.Remove(
parameter.ParameterSetName
);
}
Logger.Debug(
"Parameter {Parameter} has a value set, keeping {ParameterSetName} as a candidate",
parameter.Name,
parameter.ParameterSetName
);
return candidates;
}