本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# TypeSyntax.GetType方法的具体用法?C# TypeSyntax.GetType怎么用?C# TypeSyntax.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax
的用法示例。
在下文中一共展示了TypeSyntax.GetType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: checkTypeIsInterface
private bool checkTypeIsInterface(TypeSyntax syntax)
{
if (syntax is IdentifierNameSyntax)
{
var i = syntax as IdentifierNameSyntax;
return checkIdentifierIsInterface(i.Identifier);
}
else if (syntax is QualifiedNameSyntax)
{
var q = syntax as QualifiedNameSyntax;
return checkTypeIsInterface(q.Right);
}
else if (syntax is GenericNameSyntax)
{
var g = syntax as GenericNameSyntax;
return checkIdentifierIsInterface(g.Identifier);
}
else
{
throw new Exception("Unknown type : " + syntax.GetType());
}
}
示例2: writeType
private void writeType(TypeSyntax syntax)
{
if (syntax is PredefinedTypeSyntax)
{
PredefinedTypeSyntax p = syntax as PredefinedTypeSyntax;
JavaScriptTypeNameAndUniqunessPair jsType;
if (PredefinedTypeToJavaScriptTypeConvertingMap.getInstance().TryGetValue(p.Keyword.ToString(), out jsType))
{
writer.Write(jsType.Name);
if (!jsType.Uniquness)
writer.Write(" /* " + p.Keyword + " */");
}
else
{
throw new Exception("Unknown predefined type : " + p.Keyword);
}
}
else if (syntax is IdentifierNameSyntax)
{
IdentifierNameSyntax i = (IdentifierNameSyntax)syntax;
writer.Write(i.Identifier);
}
else if (syntax is GenericNameSyntax)
{
GenericNameSyntax g = syntax as GenericNameSyntax;
writer.Write(g.Identifier);
writer.Write("<");
bool isFirst = true;
foreach (var arg in g.TypeArgumentList.Arguments)
{
if (isFirst)
isFirst = false;
else
writer.Write(", ");
writeType(arg);
}
writer.Write(">");
}
else if (syntax is QualifiedNameSyntax)
{
QualifiedNameSyntax q = (QualifiedNameSyntax)syntax;
writeType(q.Left);
writer.Write(".");
writeType(q.Right);
}
else if (syntax is ArrayTypeSyntax)
{
var a = syntax as ArrayTypeSyntax;
writeType(a.ElementType);
if (a.RankSpecifiers.Count != 1)
{
throw new Exception("More than one rank specifiers not supported");
}
var r = a.RankSpecifiers[0];
if (r.Rank != 1)
{
throw new Exception("Rank 2 or more not supported");
}
writer.Write("[]");
}
else
{
throw new Exception("Unknown type : " + syntax.GetType());
}
}