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());
     }
 }
 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());
     }
 }