本文整理汇总了C#中SyntaxTrivia.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# SyntaxTrivia.GetType方法的具体用法?C# SyntaxTrivia.GetType怎么用?C# SyntaxTrivia.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SyntaxTrivia
的用法示例。
在下文中一共展示了SyntaxTrivia.GetType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddTrivia
private void AddTrivia(TreeViewItem parentItem, SyntaxTrivia trivia, bool isLeadingTrivia)
{
var kind = trivia.GetKind();
var tag = new SyntaxTag()
{
SyntaxTrivia = trivia,
Category = SyntaxCategory.SyntaxTrivia,
Span = trivia.Span,
FullSpan = trivia.FullSpan,
Kind = kind,
ParentItem = parentItem
};
var item = new TreeViewItem()
{
Tag = tag,
IsExpanded = false,
Foreground = Brushes.Maroon,
Background = trivia.ContainsDiagnostics ? Brushes.Pink : Brushes.White,
Header = (isLeadingTrivia ? "Lead: " : "Trail: ") + tag.Kind + " " + trivia.Span.ToString()
};
if (SyntaxTree != null && trivia.ContainsDiagnostics)
{
item.ToolTip = string.Empty;
foreach (var diagnostic in SyntaxTree.GetDiagnostics(trivia))
{
item.ToolTip += diagnostic.ToString() + "\n";
}
item.ToolTip = item.ToolTip.ToString().Trim();
}
item.Selected += new RoutedEventHandler((sender, e) =>
{
_isNavigatingFromTreeToSource = true;
typeTextLabel.Visibility = Visibility.Visible;
kindTextLabel.Visibility = Visibility.Visible;
typeValueLabel.Content = trivia.GetType().Name;
kindValueLabel.Content = kind;
_propertyGrid.SelectedObject = trivia;
item.IsExpanded = true;
if (!_isNavigatingFromSourceToTree && SyntaxTriviaNavigationToSourceRequested != null)
{
SyntaxTriviaNavigationToSourceRequested(trivia);
}
_isNavigatingFromTreeToSource = false;
e.Handled = true;
});
item.Expanded += new RoutedEventHandler((sender, e) =>
{
if (item.Items.Count == 1 && item.Items[0] == null)
{
// Remove placeholder child and populate real children.
item.Items.RemoveAt(0);
AddNode(item, trivia.GetStructure());
}
});
if (parentItem == null)
{
treeView.Items.Clear();
treeView.Items.Add(item);
typeTextLabel.Visibility = Visibility.Hidden;
kindTextLabel.Visibility = Visibility.Hidden;
typeValueLabel.Content = string.Empty;
kindValueLabel.Content = string.Empty;
}
else
{
parentItem.Items.Add(item);
}
if (trivia.HasStructure)
{
if (IsLazy)
{
// Add placeholder child to indicate that real children need to be populated on expansion.
item.Items.Add(null);
}
else
{
// Recursively populate all descendants.
AddNode(item, trivia.GetStructure());
}
}
}