本文整理汇总了C#中Microsoft.CodeAnalysis.Diagnostics.CompilationEvent.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# CompilationEvent.GetType方法的具体用法?C# CompilationEvent.GetType怎么用?C# CompilationEvent.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.Diagnostics.CompilationEvent
的用法示例。
在下文中一共展示了CompilationEvent.GetType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessEventCore
private void ProcessEventCore(CompilationEvent e, AnalysisScope analysisScope, AnalysisState analysisStateOpt, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
var symbolEvent = e as SymbolDeclaredCompilationEvent;
if (symbolEvent != null)
{
ProcessSymbolDeclared(symbolEvent, analysisScope, analysisStateOpt, cancellationToken);
return;
}
var completedEvent = e as CompilationUnitCompletedEvent;
if (completedEvent != null)
{
ProcessCompilationUnitCompleted(completedEvent, analysisScope, analysisStateOpt, cancellationToken);
return;
}
var endEvent = e as CompilationCompletedEvent;
if (endEvent != null)
{
ProcessCompilationCompleted(endEvent, analysisScope, analysisStateOpt, cancellationToken);
return;
}
var startedEvent = e as CompilationStartedEvent;
if (startedEvent != null)
{
ProcessCompilationStarted(startedEvent, analysisScope, analysisStateOpt, cancellationToken);
return;
}
throw new InvalidOperationException("Unexpected compilation event of type " + e.GetType().Name);
}
示例2: ProcessEventAsync
private async Task ProcessEventAsync(CompilationEvent e, CancellationToken cancellationToken)
{
var symbolEvent = e as SymbolDeclaredCompilationEvent;
if (symbolEvent != null)
{
await ProcessSymbolDeclared(symbolEvent, cancellationToken).ConfigureAwait(false);
return;
}
var completedEvent = e as CompilationUnitCompletedEvent;
if (completedEvent != null)
{
await ProcessCompilationUnitCompleted(completedEvent, cancellationToken).ConfigureAwait(false);
return;
}
var endEvent = e as CompilationCompletedEvent;
if (endEvent != null)
{
await ProcessCompilationCompletedAsync(endEvent, cancellationToken).ConfigureAwait(false);
return;
}
throw new InvalidOperationException("Unexpected compilation event of type " + e.GetType().Name);
}
示例3: UpdateEventsMap_NoLock
private void UpdateEventsMap_NoLock(CompilationEvent compilationEvent, bool add)
{
var symbolEvent = compilationEvent as SymbolDeclaredCompilationEvent;
if (symbolEvent != null)
{
// Add/remove symbol events.
// Any diagnostics request for a tree should trigger symbol and syntax node analysis for symbols with at least one declaring reference in the tree.
foreach (var location in symbolEvent.Symbol.Locations)
{
if (location.SourceTree != null)
{
if (add)
{
AddPendingSourceEvent_NoLock(location.SourceTree, compilationEvent);
}
else
{
RemovePendingSourceEvent_NoLock(location.SourceTree, compilationEvent);
}
}
}
}
else
{
// Add/remove compilation unit completed events.
var compilationUnitCompletedEvent = compilationEvent as CompilationUnitCompletedEvent;
if (compilationUnitCompletedEvent != null)
{
var tree = compilationUnitCompletedEvent.SemanticModel.SyntaxTree;
if (add)
{
AddPendingSourceEvent_NoLock(tree, compilationEvent);
}
else
{
RemovePendingSourceEvent_NoLock(tree, compilationEvent);
}
}
else if (compilationEvent is CompilationStartedEvent || compilationEvent is CompilationCompletedEvent)
{
// Add/remove compilation events.
if (add)
{
_pendingNonSourceEvents.Add(compilationEvent);
}
else
{
_pendingNonSourceEvents.Remove(compilationEvent);
}
}
else
{
throw new InvalidOperationException("Unexpected compilation event of type " + compilationEvent.GetType().Name);
}
}
}
示例4: ProcessEventCoreAsync
private Task ProcessEventCoreAsync(CompilationEvent e, CancellationToken cancellationToken)
{
var symbolEvent = e as SymbolDeclaredCompilationEvent;
if (symbolEvent != null)
{
return ProcessSymbolDeclaredAsync(symbolEvent, cancellationToken);
}
var completedEvent = e as CompilationUnitCompletedEvent;
if (completedEvent != null)
{
return ProcessCompilationUnitCompletedAsync(completedEvent, cancellationToken);
}
var endEvent = e as CompilationCompletedEvent;
if (endEvent != null)
{
return ProcessCompilationCompletedAsync(endEvent, cancellationToken);
}
if (e is CompilationStartedEvent)
{
// Ignore CompilationStartedEvent.
return null;
}
throw new InvalidOperationException("Unexpected compilation event of type " + e.GetType().Name);
}