本文整理汇总了C#中AstNode.GetProperties方法的典型用法代码示例。如果您正苦于以下问题:C# AstNode.GetProperties方法的具体用法?C# AstNode.GetProperties怎么用?C# AstNode.GetProperties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AstNode
的用法示例。
在下文中一共展示了AstNode.GetProperties方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetLeafNodeString
public static string GetLeafNodeString(AstNode node)
{
string nodeRole = node.Role.ToString();
var properties = node.GetProperties();
if (nodeRole == "Comment")
{
CommentType commentType = properties.GetPropertyValueEnum<CommentType>(node, "CommentType");
string content = properties.GetPropertyValue(node, "Content");
switch (commentType)
{
default:
case CommentType.SingleLine:
return "//" + content;
case CommentType.Documentation:
return "///" + content;
case CommentType.MultiLine:
return "/*" + content + "*/";
case CommentType.InactiveCode:
return content;
case CommentType.MultiLineDocumentation:
return "/**" + content + "*/";
}
}
else if (nodeRole == "Modifier")
{
return properties.GetPropertyValue(node, "Modifier").ToLower();
}
else if (nodeRole == "Target" || nodeRole == "Right")
{
string typeName = node.GetType().Name;
if (typeName == nameof(ThisReferenceExpression))
return "this";
else if (typeName == nameof(BaseReferenceExpression))
return "base";
else if (typeName == nameof(NullReferenceExpression))
return "null";
}
else if (nodeRole == "PreProcessorDirective")
{
var type = properties.GetPropertyValue(node, "Type").ToLower();
var argument = properties.GetPropertyValue(node, "Argument");
var result = "#" + type;
if (argument != string.Empty)
result += " " + argument;
return result;
}
if (node is ThisReferenceExpression)
return "this";
else if (node is BaseReferenceExpression)
return "base";
else if (node is NullReferenceExpression)
return "null";
else if (node is CSharpTokenNode || node is CSharpModifierToken)
return nodeRole;
else if (node is NewLineNode)
return "";
return properties
.FirstOrDefault(p => NameKeys.Contains(p.Name))
.GetValue(node, null)
.ToString();
}