本文整理汇总了C#中Microsoft.CodeAnalysis.ProjectState.GetDocumentState方法的典型用法代码示例。如果您正苦于以下问题:C# ProjectState.GetDocumentState方法的具体用法?C# ProjectState.GetDocumentState怎么用?C# ProjectState.GetDocumentState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.ProjectState
的用法示例。
在下文中一共展示了ProjectState.GetDocumentState方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateLinkedFilesMapWithRemovedDocuments
private ImmutableDictionary<string, ImmutableArray<DocumentId>> CreateLinkedFilesMapWithRemovedDocuments(
ProjectState projectState,
IEnumerable<DocumentId> documentIds)
{
var builder = _linkedFilesMap.ToBuilder();
foreach (var documentId in documentIds)
{
var filePath = projectState.GetDocumentState(documentId).FilePath;
if (string.IsNullOrEmpty(filePath))
{
continue;
}
ImmutableArray<DocumentId> documentIdsWithPath;
if (!builder.TryGetValue(filePath, out documentIdsWithPath) || !documentIdsWithPath.Contains(documentId))
{
throw new ArgumentException("The given documentId was not found in the linkedFilesMap.");
}
if (documentIdsWithPath.Length == 1)
{
builder.Remove(filePath);
}
else
{
builder[filePath] = documentIdsWithPath.Remove(documentId);
}
}
return builder.ToImmutable();
}
示例2: CreateLinkedFilesMapWithAddedDocuments
private ImmutableDictionary<string, ImmutableArray<DocumentId>> CreateLinkedFilesMapWithAddedDocuments(ProjectState projectState, IEnumerable<DocumentId> documentIds)
{
var builder = _linkedFilesMap.ToBuilder();
foreach (var documentId in documentIds)
{
var filePath = projectState.GetDocumentState(documentId).FilePath;
if (string.IsNullOrEmpty(filePath))
{
continue;
}
ImmutableArray<DocumentId> documentIdsWithPath;
builder[filePath] = builder.TryGetValue(filePath, out documentIdsWithPath)
? documentIdsWithPath.Add(documentId)
: ImmutableArray.Create(documentId);
}
return builder.ToImmutable();
}