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


C# Class.isPrimitive方法代码示例

本文整理汇总了C#中java.lang.Class.isPrimitive方法的典型用法代码示例。如果您正苦于以下问题:C# Class.isPrimitive方法的具体用法?C# Class.isPrimitive怎么用?C# Class.isPrimitive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.lang.Class的用法示例。


在下文中一共展示了Class.isPrimitive方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: getCPPTypeName

 public static string getCPPTypeName(Class type)
 {
   if (type == ClassLiteral<Buffer>.Value || type == ClassLiteral<Pointer>.Value)
     return "void*";
   if (type == ClassLiteral<byte[]>.Value || type == ClassLiteral<ByteBuffer>.Value || type == ClassLiteral<BytePointer>.Value)
     return "signed char*";
   if (type == ClassLiteral<short[]>.Value || type == ClassLiteral<ShortBuffer>.Value || type == ClassLiteral<ShortPointer>.Value)
     return "short*";
   if (type == ClassLiteral<int[]>.Value || type == ClassLiteral<IntBuffer>.Value || type == ClassLiteral<IntPointer>.Value)
     return "int*";
   if (type == ClassLiteral<long[]>.Value || type == ClassLiteral<LongBuffer>.Value || type == ClassLiteral<LongPointer>.Value)
     return "jlong*";
   if (type == ClassLiteral<float[]>.Value || type == ClassLiteral<FloatBuffer>.Value || type == ClassLiteral<FloatPointer>.Value)
     return "float*";
   if (type == ClassLiteral<double[]>.Value || type == ClassLiteral<DoubleBuffer>.Value || type == ClassLiteral<DoublePointer>.Value)
     return "double*";
   if (type == ClassLiteral<char[]>.Value || type == ClassLiteral<CharBuffer>.Value || type == ClassLiteral<CharPointer>.Value)
     return "unsigned short*";
   if (type == ClassLiteral<PointerPointer>.Value)
     return "void**";
   if (type == ClassLiteral<String>.Value)
     return "const char*";
   if (type == Byte.TYPE)
     return "signed char";
   if (type == Character.TYPE)
     return "unsigned short";
   if (type == Long.TYPE)
     return "jlong";
   if (type == Boolean.TYPE)
     return "unsigned char";
   if (type.isPrimitive())
     return type.getName();
   else if (((Class) ClassLiteral<FunctionPointer>.Value).isAssignableFrom(type))
   {
     return new StringBuilder().append("JavaCPP_").append(Generator.mangle(type.getName())).append("*").toString();
   }
   else
   {
     string str1 = "";
     for (; type != null; type = type.getDeclaringClass())
     {
       Namespace @namespace = (Namespace) type.getAnnotation((Class) ClassLiteral<Namespace>.Value);
       string str2 = @namespace == null ? "" : @namespace.value();
       if (((Class) ClassLiteral<Pointer>.Value).isAssignableFrom(type))
       {
         Name name1 = (Name) type.getAnnotation((Class) ClassLiteral<Name>.Value);
         string str3;
         if (name1 == null)
         {
           string name2 = type.getName();
           str3 = String.instancehelper_substring(name2, String.instancehelper_lastIndexOf(name2, "$") + 1);
         }
         else
           str3 = name1.value();
         str2 = String.instancehelper_length(str2) != 0 ? new StringBuilder().append(str2).append("::").append(str3).toString() : str3;
       }
       if (String.instancehelper_length(str1) == 0)
         str1 = str2;
       else if (String.instancehelper_length(str2) > 0)
         str1 = new StringBuilder().append(str2).append("::").append(str1).toString();
     }
     return new StringBuilder().append(str1).append("*").toString();
   }
 }
开发者ID:NALSS,项目名称:SmartDashboard.NET,代码行数:64,代码来源:Generator.cs

示例2: JavaSignature

 internal static string JavaSignature(Class clazz)
 {
     string name = clazz.FullName;
     if (clazz.isPrimitive())
     {
         switch (name)
         {
             case "boolean":
                 return "Z";
             case "int":
                 return "I";
             case "double":
                 return "D";
             case "float":
                 return "F";
             case "short":
                 return "S";
             case "long":
                 return "J";
             case "char":
                 return "C";
             case "byte":
                 return "B";
             case "void":
                 return "V";
             default:
                 throw new NotImplementedException();
         }
     }
     if (clazz.isArray())
     {
         return name.Replace('.', '/');
     }
     return "L" + name.Replace('.', '/') + ";";
 }
开发者ID:modulexcite,项目名称:Fork_Jni4Net,代码行数:35,代码来源:Registry.helpers.cs

示例3: RegisterClass

        internal static GType RegisterClass(Class clazz, TypeRegistration registration)
        {
            if (knownClasses.ContainsKey(clazz))
            {
                GType known = knownClasses[clazz];
                if (registration != null)
                {
                    known.Registration = registration;
                }
                return known;
            }
            var res = new GType();
            if (clazz.isArray())
            {
                res.ArrayElement = RegisterClass(clazz.getComponentType(), null);
                res.IsArray = true;
                string array = "[]";
                Class comp = clazz.getComponentType();
                while (comp.isArray())
                {
                    array += "[]";
                    comp = comp.getComponentType();
                }
                res.LowerName = ((string) comp.getName()).ToLowerInvariant() + array;
            }
            else
            {
                res.LowerName = ((string) clazz.getName()).ToLowerInvariant();
            }

            res.Attributes = 0;
            var classModifiers = (ModifierFlags) clazz.getModifiers();
            if ((classModifiers & ModifierFlags.Abstract) != 0)
            {
                res.IsAbstract = true;
                res.Attributes |= TypeAttributes.Abstract;
            }
            if ((classModifiers & ModifierFlags.Final) != 0)
            {
                res.IsFinal = true;
            }
            if ((classModifiers & ModifierFlags.Public) != 0)
            {
                res.Attributes |= TypeAttributes.Public;
            }
            else if ((classModifiers & ModifierFlags.Private) != 0)
            {
                res.Attributes |= TypeAttributes.NotPublic;
            }
            //TODO internal ?
            if (knownNames.ContainsKey(res.LowerName))
            {
                res = knownNames[res.LowerName];
            }
            if (res.Registration == null && registration != null)
            {
                res.Registration = registration;
            }
            res.JVMType = clazz;
            res.JVMFullName = clazz.getName();
            if (res.IsArray)
            {
                string array = "[]";
                Class comp = clazz.getComponentType();
                while (comp.isArray())
                {
                    array += "[]";
                    comp = comp.getComponentType();
                }
                res.JVMFullName = comp.getName() + array;
            }
            else
            {
                res.JVMFullName = clazz.getName();
            }
            res.IsJVMType = true;
            res.IsPrimitive = clazz.isPrimitive();
            res.IsException = Throwable._class.isAssignableFrom(clazz);
            res.IsInterface = clazz.isInterface();
            res.IsCLRProxy = clrProxyClass != null && clrProxyClass.isAssignableFrom(clazz);
            if (!res.IsCLRProxy)
            {
                res.IsJVMRealType = true;
            }
            Class superclass = clazz.getSuperclass();
            var isBaseClassPublic = superclass == null || ((ModifierFlags)superclass.getModifiers() & ModifierFlags.Public) != 0;
            if (superclass != null && res.Base == null
                && clazz != Object._class
                && clazz != Throwable._class
                && res.JVMFullName != "system.Object"
                && res.JVMFullName != "system.Exception"
                && isBaseClassPublic)
            {
                res.Base = RegisterClass(superclass);
            }
            List<Class> interfaces = new List<Class>(clazz.getInterfaces());
            if (!isBaseClassPublic)
            {
                interfaces.AddRange(superclass.getInterfaces());
                res.Base = RegisterClass(superclass.getSuperclass());
//.........这里部分代码省略.........
开发者ID:Mazrick,项目名称:jni4net,代码行数:101,代码来源:Repository.JVM.cs


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