本文整理汇总了C#中IImmutableSet类的典型用法代码示例。如果您正苦于以下问题:C# IImmutableSet类的具体用法?C# IImmutableSet怎么用?C# IImmutableSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IImmutableSet类属于命名空间,在下文中一共展示了IImmutableSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindDocumentsAsync
protected async Task<ImmutableArray<Document>> FindDocumentsAsync(Project project, IImmutableSet<Document> scope, Func<Document, CancellationToken, Task<bool>> predicateAsync, CancellationToken cancellationToken)
{
// special case for HR
if (scope != null && scope.Count == 1)
{
var document = scope.First();
if (document.Project == project)
{
return scope.ToImmutableArray();
}
return ImmutableArray<Document>.Empty;
}
var documents = ArrayBuilder<Document>.GetInstance();
foreach (var document in project.Documents)
{
if (scope != null && !scope.Contains(document))
{
continue;
}
if (await predicateAsync(document, cancellationToken).ConfigureAwait(false))
{
documents.Add(document);
}
}
return documents.ToImmutableAndFree();
}
示例2: FindReferencesInServiceProcessAsync
private static async Task FindReferencesInServiceProcessAsync(
SymbolAndProjectId symbolAndProjectId,
Solution solution,
IStreamingFindReferencesProgress progress,
IImmutableSet<Document> documents,
CancellationToken cancellationToken)
{
var client = await solution.Workspace.GetRemoteHostClientAsync(cancellationToken).ConfigureAwait(false);
if (client == null)
{
await FindReferencesInCurrentProcessAsync(
symbolAndProjectId, solution, progress, documents, cancellationToken).ConfigureAwait(false);
return;
}
// Create a callback that we can pass to the server process to hear about the
// results as it finds them. When we hear about results we'll forward them to
// the 'progress' parameter which will then upate the UI.
var serverCallback = new ServerCallback(solution, progress, cancellationToken);
using (var session = await client.CreateCodeAnalysisServiceSessionAsync(
solution, serverCallback, cancellationToken).ConfigureAwait(false))
{
await session.InvokeAsync(
nameof(IRemoteSymbolFinder.FindReferencesAsync),
SerializableSymbolAndProjectId.Dehydrate(symbolAndProjectId),
documents?.Select(SerializableDocumentId.Dehydrate).ToArray()).ConfigureAwait(false);
}
}
示例3: MetadataDefinitionState
public MetadataDefinitionState(MetadataDefinitionName name, IDataType datatype, string regex, IImmutableSet<AllowableValue> allowedValues)
: this(name, datatype,regex)
{
_allowedValues = allowedValues;
CreatedUtcDate = DateTime.UtcNow;
IsDeleted = false;
}
示例4: FindDerivedClassesAsync
private static Task<IEnumerable<INamedTypeSymbol>> FindDerivedClassesAsync(
INamedTypeSymbol type,
Solution solution,
IImmutableSet<Project> projects,
bool transitive,
CancellationToken cancellationToken)
{
if (s_isNonSealedClass(type))
{
Func<HashSet<INamedTypeSymbol>, INamedTypeSymbol, bool> metadataTypeMatches =
(set, metadataType) => TypeDerivesFrom(set, metadataType, transitive);
Func<HashSet<INamedTypeSymbol>, INamedTypeSymbol, bool> sourceTypeImmediatelyMatches =
(set, metadataType) => set.Contains(metadataType.BaseType?.OriginalDefinition);
return FindTypesAsync(type, solution, projects,
metadataTypeMatches: metadataTypeMatches,
sourceTypeImmediatelyMatches: sourceTypeImmediatelyMatches,
shouldContinueSearching: s_isNonSealedClass,
transitive: transitive,
cancellationToken: cancellationToken);
}
return SpecializedTasks.EmptyEnumerable<INamedTypeSymbol>();
}
示例5: BuildUp
public override IEnumerable<SlideBlock> BuildUp(BuildUpContext context, IImmutableSet<string> filesInProgress)
{
FillProperties(context);
RemovedLabels = RemovedLabels ?? new Label[0];
if (PreludeFile == null)
{
PreludeFile = context.CourseSettings.GetPrelude(LangId);
if (PreludeFile != null)
PreludeFile = Path.Combine("..", PreludeFile);
}
var code = context.FileSystem.GetContent(File);
var regionRemover = new RegionRemover(LangId);
var extractor = context.GetExtractor(File, LangId, code);
var prelude = "";
if (PreludeFile != null)
prelude = context.FileSystem.GetContent(PreludeFile);
var exerciseCode = regionRemover.Prepare(code);
IEnumerable<Label> notRemoved;
exerciseCode = regionRemover.Remove(exerciseCode, RemovedLabels, out notRemoved);
int index;
exerciseCode = regionRemover.RemoveSolution(exerciseCode, SolutionLabel, out index);
index += prelude.Length;
ExerciseInitialCode = ExerciseInitialCode.RemoveCommonNesting();
ExerciseCode = prelude + exerciseCode;
IndexToInsertSolution = index;
EthalonSolution = extractor.GetRegion(SolutionLabel);
ValidatorName = string.Join(" ", LangId, ValidatorName);
yield return this;
}
示例6: GetCommandStatusAsync
public Task<CommandStatusResult> GetCommandStatusAsync(IImmutableSet<IProjectTree> nodes, long commandId, bool focused, string commandText, CommandStatus progressiveStatus) {
var workflow = _interactiveWorkflowProvider.GetOrCreate();
if (commandId == RPackageCommandId.icmdCopyRemoteItemPath && nodes.IsSingleNodePath() && workflow.RSession.IsHostRunning && workflow.RSession.IsRemote) {
return Task.FromResult(new CommandStatusResult(true, commandText, CommandStatus.Enabled | CommandStatus.Supported));
}
return Task.FromResult(CommandStatusResult.Unhandled);
}
示例7: GetCommandStatus
public CommandStatusResult GetCommandStatus(IImmutableSet<IProjectTree> nodes, long commandId, bool focused, string commandText, CommandStatus progressiveStatus) {
if ((VSConstants.VSStd2KCmdID)commandId == VSConstants.VSStd2KCmdID.EXCLUDEFROMPROJECT && nodes != null && nodes.Count > 0) {
return new CommandStatusResult(true, commandText, CommandStatus.NotSupported | CommandStatus.Invisible);
}
return CommandStatusResult.Unhandled;
}
示例8: GetDocumentHighlightsAsync
public async Task<ImmutableArray<DocumentHighlights>> GetDocumentHighlightsAsync(
Document document, int position, IImmutableSet<Document> documentsToSearch, CancellationToken cancellationToken)
{
// use speculative semantic model to see whether we are on a symbol we can do HR
var span = new TextSpan(position, 0);
var solution = document.Project.Solution;
var semanticModel = await document.GetSemanticModelForSpanAsync(span, cancellationToken).ConfigureAwait(false);
var symbol = await SymbolFinder.FindSymbolAtPositionAsync(
semanticModel, position, solution.Workspace, cancellationToken).ConfigureAwait(false);
if (symbol == null)
{
return ImmutableArray<DocumentHighlights>.Empty;
}
symbol = await GetSymbolToSearchAsync(document, position, semanticModel, symbol, cancellationToken).ConfigureAwait(false);
if (symbol == null)
{
return ImmutableArray<DocumentHighlights>.Empty;
}
// Get unique tags for referenced symbols
return await GetTagsForReferencedSymbolAsync(
new SymbolAndProjectId(symbol, document.Project.Id), documentsToSearch,
solution, cancellationToken).ConfigureAwait(false);
}
示例9: DetermineCascadedSymbolsAsync
public async Task<IEnumerable<ISymbol>> DetermineCascadedSymbolsAsync(ISymbol symbol, Solution solution, IImmutableSet<Project> projects = null, CancellationToken cancellationToken = default(CancellationToken))
{
var linkedSymbols = new HashSet<ISymbol>();
foreach (var location in symbol.DeclaringSyntaxReferences)
{
var originalDocument = solution.GetDocument(location.SyntaxTree);
foreach (var linkedDocumentId in originalDocument.GetLinkedDocumentIds())
{
var linkedDocument = solution.GetDocument(linkedDocumentId);
var linkedSyntaxRoot = await linkedDocument.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
var linkedNode = linkedSyntaxRoot.FindNode(location.Span, getInnermostNodeForTie: true);
var semanticModel = await linkedDocument.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
var linkedSymbol = semanticModel.GetDeclaredSymbol(linkedNode, cancellationToken);
if (linkedSymbol != null &&
linkedSymbol.Kind == symbol.Kind &&
linkedSymbol.Name == symbol.Name &&
!linkedSymbols.Contains(linkedSymbol))
{
linkedSymbols.Add(linkedSymbol);
}
}
}
return linkedSymbols;
}
示例10: FindReferencesAsync
/// <summary>
/// Finds all references to a symbol throughout a solution
/// </summary>
/// <param name="symbol">The symbol to find references to.</param>
/// <param name="solution">The solution to find references within.</param>
/// <param name="documents">A set of documents to be searched. If documents is null, then that means "all documents".</param>
/// <param name="cancellationToken">A cancellation token.</param>
public static Task<IEnumerable<ReferencedSymbol>> FindReferencesAsync(
ISymbol symbol,
Solution solution,
IImmutableSet<Document> documents,
CancellationToken cancellationToken = default(CancellationToken))
{
return FindReferencesAsync(symbol, solution, progress: null, documents: documents, cancellationToken: cancellationToken);
}
示例11: EntityState
private EntityState(Guid group, EntityName name, IImmutableSet<EntityValueSetState> values, bool deleted)
{
_group = group;
_name = name;
_values = values;
LastModifiedUtcDate = DateTime.UtcNow;
IsDeleted = deleted;
}
示例12: GetCommandStatus
public CommandStatusResult GetCommandStatus(IImmutableSet<IProjectTree> nodes, long commandId, bool focused, string commandText, CommandStatus progressiveStatus) {
if (commandId == RPackageCommandId.icmdSetDirectoryHere && nodes.Count == 1) {
var session = _interactiveWorkflowProvider.Active?.RSession;
bool enabled = session != null && session.IsHostRunning && !session.IsRemote;
return new CommandStatusResult(true, commandText, enabled ? CommandStatus.Enabled | CommandStatus.Supported : CommandStatus.Supported);
}
return CommandStatusResult.Unhandled;
}
示例13: FindImplementingTypesAsync
public static Task<IEnumerable<INamedTypeSymbol>> FindImplementingTypesAsync(
this INamedTypeSymbol type,
Solution solution,
IImmutableSet<Project> projects,
CancellationToken cancellationToken)
{
return DependentTypeFinder.FindImplementingTypesAsync(type, solution, projects, cancellationToken);
}
示例14: Role
public Role(int id, string name, string description, IImmutableSet<IRight> rights = null, PermissionsSource source = PermissionsSource.Manual)
{
this.Id = id;
this.Name = name;
this.Description = description;
this.Rights = rights.DefaultIfNull();
this.Source = source;
}
示例15: FindImplementedInterfaceMembersAsync
/// <summary>
/// Find symbols for declarations that implement members of the specified interface symbol
/// </summary>
public static async Task<IEnumerable<ISymbol>> FindImplementedInterfaceMembersAsync(
ISymbol symbol, Solution solution, IImmutableSet<Project> projects = null, CancellationToken cancellationToken = default(CancellationToken))
{
var result = await FindImplementedInterfaceMembersAsync(
SymbolAndProjectId.Create(symbol, projectId: null),
solution, projects, cancellationToken).ConfigureAwait(false);
return result.SelectAsArray(s => s.Symbol);
}