当前位置: 首页>>代码示例>>C#>>正文


C# TypeSyntax.GetType方法代码示例

本文整理汇总了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());
     }
 }
开发者ID:nobuoka,项目名称:WindowsRuntimeTSDeclaration,代码行数:22,代码来源:TsDeclarationGenerator.cs

示例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());
     }
 }
开发者ID:nobuoka,项目名称:WindowsRuntimeTSDeclaration,代码行数:65,代码来源:TsDeclarationGenerator.cs


注:本文中的Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。