當前位置: 首頁>>代碼示例>>C#>>正文


C# TypeNode.GetFullUnmangledNameWithoutTypeParameters方法代碼示例

本文整理匯總了C#中System.Compiler.TypeNode.GetFullUnmangledNameWithoutTypeParameters方法的典型用法代碼示例。如果您正苦於以下問題:C# TypeNode.GetFullUnmangledNameWithoutTypeParameters方法的具體用法?C# TypeNode.GetFullUnmangledNameWithoutTypeParameters怎麽用?C# TypeNode.GetFullUnmangledNameWithoutTypeParameters使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Compiler.TypeNode的用法示例。


在下文中一共展示了TypeNode.GetFullUnmangledNameWithoutTypeParameters方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetTypeNameFor

 public static string GetTypeNameFor(TypeNode type, bool suppressTemplateParameters, bool fullName){
   if (type == null || type.Name == Looker.NotFound) return "";
   switch(type.TypeCode){
     case TypeCode.Boolean: return "bool";
     case TypeCode.Byte: return "byte";
     case TypeCode.Char: return "char";
     case TypeCode.Decimal: return "decimal";
     case TypeCode.Double: return "double";
     case TypeCode.Int16: return "short";
     case TypeCode.Int32: return "int";
     case TypeCode.Int64: return "long";
     case TypeCode.SByte: return "sbyte";
     case TypeCode.Single: return "float";
     case TypeCode.String: return "string";
     case TypeCode.UInt16: return "ushort";
     case TypeCode.UInt32: return "uint";
     case TypeCode.UInt64: return "ulong";
   }
   if (type == SystemTypes.Object) return "object";
   if (type == SystemTypes.Void) return "void";
   if (type.Template == SystemTypes.GenericNullable){
     if (type.TemplateArguments != null && type.TemplateArguments.Count > 0)
       return ErrorHandler.GetTypeNameFor(type.TemplateArguments[0]) + "?";
   }
   switch (type.NodeType){
     case NodeType.ArrayType:
       ArrayType aType = (ArrayType)type;
       StringBuilder sb = new StringBuilder(ErrorHandler.GetTypeNameFor(aType.ElementType));
       sb.Append('[');
       for (int i = 0, n = aType.Rank; i < n; i++){
         if (i == 0 && n > 1) sb.Append('*');
         if (i < n-1){
           sb.Append(',');
           if (n > 1) sb.Append('*');
         }
       }
       sb.Append(']');
       return sb.ToString();
     case NodeType.Class:
       FunctionType fType = type as FunctionType;
       if (fType != null){
         ErrorHandler eh = new ErrorHandler(new ErrorNodeList(0));
         return "delegate " + eh.GetTypeName(fType.ReturnType)+" "+eh.GetSignatureString("", fType.Parameters, "(", ")", ", ");
       }
       ClosureClass cClass = type as ClosureClass;
       if (cClass != null){
         MemberList mems = cClass.Members;
         for (int i = 0, n = mems == null ? 0 : mems.Count; i < n; i++){
           Method meth = mems[i] as Method;
           if (meth == null || meth is InstanceInitializer || (meth.Parameters != null && meth.Parameters.Count != 0)) continue;
           return ErrorHandler.GetTypeNameFor(meth.ReturnType);
         }
       }
       if (type.Template != null && type.TemplateArguments != null && type.TemplateArguments.Count > 0){
         sb = new StringBuilder(ErrorHandler.GetTypeNameFor(type.Template, true, fullName));
         for (int i = 0, n = type.TemplateArguments == null ? 0 : type.TemplateArguments.Count; i < n; i++){
           if (i == 0) sb.Append('<');
           sb.Append(ErrorHandler.GetTypeNameFor(type.TemplateArguments[i]));
           if (i < n - 1) sb.Append(','); else sb.Append('>');
         }
         return sb.ToString();
       }
       if (type.DeclaringType != null)
         sb = new StringBuilder(ErrorHandler.GetTypeNameFor(type.DeclaringType)+"."+type.GetUnmangledNameWithoutTypeParameters());
       else
         sb = new StringBuilder(type.GetFullUnmangledNameWithoutTypeParameters());
       if (!suppressTemplateParameters && type.TemplateParameters != null){
         for (int i = 0, n = type.TemplateParameters == null ? 0 : type.TemplateParameters.Count; i < n; i++){
           if (i == 0) sb.Append('<');
           sb.Append(ErrorHandler.GetTypeNameFor(type.TemplateParameters[i], false, fullName));
           if (i < n - 1) sb.Append(','); else sb.Append('>');
         }
         return sb.ToString();
       }
       return sb.ToString();
     case NodeType.ConstrainedType:
     case NodeType.DelegateNode:
     case NodeType.EnumNode:
     case NodeType.Interface:
     case NodeType.TypeAlias:
       goto case NodeType.Class;
     case NodeType.OptionalModifier:
       if (((OptionalModifier)type).Modifier == SystemTypes.NonNullType)
         return ErrorHandler.GetTypeNameFor(((OptionalModifier)type).ModifiedType)+"!";
       if (((OptionalModifier)type).Modifier == SystemTypes.NullableType)
         return ErrorHandler.GetTypeNameFor(((OptionalModifier)type).ModifiedType) + "?";
       goto case NodeType.RequiredModifier;
     case NodeType.RequiredModifier:
       return ErrorHandler.GetTypeNameFor(((TypeModifier)type).ModifiedType);
     case NodeType.Pointer:
       return ErrorHandler.GetTypeNameFor(((Pointer)type).ElementType)+"*";
     case NodeType.Reference:
       return "ref "+ErrorHandler.GetTypeNameFor(((Reference)type).ElementType);
     case NodeType.Refanytype:
     case NodeType.Struct:
       goto case NodeType.Class;
     case NodeType.ClassParameter:
     case NodeType.TypeParameter:
       return type.Name.ToString();
     case NodeType.ClassExpression : 
//.........這裏部分代碼省略.........
開發者ID:hesam,項目名稱:SketchSharp,代碼行數:101,代碼來源:Error.cs


注:本文中的System.Compiler.TypeNode.GetFullUnmangledNameWithoutTypeParameters方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。