本文整理汇总了C#中java.lang.Class.getName方法的典型用法代码示例。如果您正苦于以下问题:C# Class.getName方法的具体用法?C# Class.getName怎么用?C# Class.getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.lang.Class
的用法示例。
在下文中一共展示了Class.getName方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DotnetBaseClassFieldExtractor
public DotnetBaseClassFieldExtractor(Class clazz, string fieldName)
: base(null, null)
{
Type type = null;
foreach (Assembly assem in AppDomain.CurrentDomain.GetAssemblies())
{
type = assem.GetType(clazz.getName().Replace("cli.", ""));
if(type != null)
break;
}
this.fieldName = fieldName;
FieldInfo[] info = type.GetFields();
string fieldType = type.GetProperty(fieldName).PropertyType.FullName;
//string originalClassName = clazz.getName().Replace('.', '/');
//string className = CSClassFieldExtractorFactory.BASE_PACKAGE + "/" + originalClassName + "$" + fieldName;
try {
//this.index = getIndex(type, fieldName);
this.index = FieldIndexGenerator.getIndex();
this.fieldType = type.GetProperty(fieldName).PropertyType;
this.objectType = DotnetClassFieldExtractorFactory.getClassObjectType( this.fieldType );
} catch ( System.Exception e ) {
throw new RuntimeDroolsException( e );
}
}
示例2: testFromSuiteMethod
public static Test testFromSuiteMethod(Class klass)
{
InvocationTargetException invocationTargetException;
try
{
Method method = klass.getMethod("suite", new Class[0], SuiteMethod.__\u003CGetCallerID\u003E());
if (Modifier.isStatic(method.getModifiers()))
return (Test) method.invoke((object) null, new object[0], SuiteMethod.__\u003CGetCallerID\u003E());
string str = new StringBuilder().append(klass.getName()).append(".suite() must be static").toString();
Throwable.__\u003CsuppressFillInStackTrace\u003E();
throw new Exception(str);
}
catch (InvocationTargetException ex)
{
int num = 1;
invocationTargetException = (InvocationTargetException) ByteCodeHelper.MapException<InvocationTargetException>((Exception) ex, (ByteCodeHelper.MapFlags) num);
}
throw Throwable.__\u003Cunmap\u003E(invocationTargetException.getCause());
}
示例3: createTestDescription
public static Description createTestDescription(Class clazz, string name, params Annotation[] annotations)
{
string str1 = "%s(%s)";
object[] objArray = new object[2];
int index1 = 0;
string str2 = name;
objArray[index1] = (object) str2;
int index2 = 1;
string name1 = clazz.getName();
objArray[index2] = (object) name1;
return new Description(String.format(str1, objArray), annotations);
}
示例4: createSuiteDescription
public static Description createSuiteDescription(Class testClass)
{
return new Description(testClass.getName(), testClass.getAnnotations());
}
示例5: createTest
public static Test createTest(Class theClass, string name)
{
Constructor testConstructor;
try
{
testConstructor = TestSuite.getTestConstructor(theClass);
goto label_3;
}
catch (NoSuchMethodException ex)
{
}
return TestSuite.warning(new StringBuilder().append("Class ").append(theClass.getName()).append(" has no public constructor TestCase(String name) or TestCase()").toString());
label_3:
object obj;
InstantiationException instantiationException1;
InvocationTargetException invocationTargetException1;
IllegalAccessException illegalAccessException1;
try
{
try
{
try
{
if (testConstructor.getParameterTypes().Length == 0)
{
obj = testConstructor.newInstance(new object[0], TestSuite.__\u003CGetCallerID\u003E());
if (obj is TestCase)
{
((TestCase) obj).setName(name);
goto label_13;
}
else
goto label_13;
}
else
{
Constructor constructor = testConstructor;
object[] objArray = new object[1];
int index = 0;
string str = name;
objArray[index] = (object) str;
CallerID callerId = TestSuite.__\u003CGetCallerID\u003E();
obj = constructor.newInstance(objArray, callerId);
goto label_13;
}
}
catch (InstantiationException ex)
{
int num = 1;
instantiationException1 = (InstantiationException) ByteCodeHelper.MapException<InstantiationException>((Exception) ex, (ByteCodeHelper.MapFlags) num);
}
}
catch (InvocationTargetException ex)
{
int num = 1;
invocationTargetException1 = (InvocationTargetException) ByteCodeHelper.MapException<InvocationTargetException>((Exception) ex, (ByteCodeHelper.MapFlags) num);
goto label_11;
}
}
catch (IllegalAccessException ex)
{
int num = 1;
illegalAccessException1 = (IllegalAccessException) ByteCodeHelper.MapException<IllegalAccessException>((Exception) ex, (ByteCodeHelper.MapFlags) num);
goto label_12;
}
InstantiationException instantiationException2 = instantiationException1;
return TestSuite.warning(new StringBuilder().append("Cannot instantiate test case: ").append(name).append(" (").append(TestSuite.exceptionToString((Exception) instantiationException2)).append(")").toString());
label_11:
InvocationTargetException invocationTargetException2 = invocationTargetException1;
return TestSuite.warning(new StringBuilder().append("Exception in constructor: ").append(name).append(" (").append(TestSuite.exceptionToString(invocationTargetException2.getTargetException())).append(")").toString());
label_12:
IllegalAccessException illegalAccessException2 = illegalAccessException1;
return TestSuite.warning(new StringBuilder().append("Cannot access test case: ").append(name).append(" (").append(TestSuite.exceptionToString((Exception) illegalAccessException2)).append(")").toString());
label_13:
return (Test) obj;
}
示例6: 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();
}
}
示例7: getSignature
public static string getSignature(Class type)
{
if (type == Byte.TYPE)
return "B";
if (type == Short.TYPE)
return "S";
if (type == Integer.TYPE)
return "I";
if (type == Long.TYPE)
return "J";
if (type == Float.TYPE)
return "F";
if (type == Double.TYPE)
return "D";
if (type == Boolean.TYPE)
return "Z";
if (type == Character.TYPE)
return "C";
if (type == Void.TYPE)
return "V";
if (type.isArray())
{
string name = type.getName();
string str = ".";
object obj1 = (object) "/";
object obj2 = (object) str;
CharSequence charSequence1;
charSequence1.__\u003Cref\u003E = (__Null) obj2;
CharSequence charSequence2 = charSequence1;
object obj3 = obj1;
charSequence1.__\u003Cref\u003E = (__Null) obj3;
CharSequence charSequence3 = charSequence1;
return String.instancehelper_replace(name, charSequence2, charSequence3);
}
else
{
StringBuilder stringBuilder = new StringBuilder().append("L");
string name = type.getName();
string str1 = ".";
object obj1 = (object) "/";
object obj2 = (object) str1;
CharSequence charSequence1;
charSequence1.__\u003Cref\u003E = (__Null) obj2;
CharSequence charSequence2 = charSequence1;
object obj3 = obj1;
charSequence1.__\u003Cref\u003E = (__Null) obj3;
CharSequence charSequence3 = charSequence1;
string str2 = String.instancehelper_replace(name, charSequence2, charSequence3);
return stringBuilder.append(str2).append(";").toString();
}
}
示例8: load
public static string load(Class cls)
{
if (!Loader.loadLibraries)
return (string) null;
string str1 = cls.getName();
int num1 = String.instancehelper_indexOf(str1, 36);
if (num1 > 0)
str1 = String.instancehelper_substring(str1, 0, num1);
ClassNotFoundException notFoundException1;
try
{
cls = Class.forName(str1, Loader.__\u003CGetCallerID\u003E());
goto label_7;
}
catch (ClassNotFoundException ex)
{
int num2 = 1;
notFoundException1 = (ClassNotFoundException) ByteCodeHelper.MapException<ClassNotFoundException>((Exception) ex, (ByteCodeHelper.MapFlags) num2);
}
ClassNotFoundException notFoundException2 = notFoundException1;
NoClassDefFoundError classDefFoundError = new NoClassDefFoundError(Throwable.instancehelper_toString((Exception) notFoundException2));
Throwable.instancehelper_initCause((Exception) classDefFoundError, (Exception) notFoundException2);
throw Throwable.__\u003Cunmap\u003E((Exception) classDefFoundError);
label_7:
string str2 = (string) Loader.loadedLibraries.get((object) cls);
if (str2 != null)
return str2;
Properties properties = (Properties) ((Hashtable) Loader.getProperties()).clone();
Loader.appendProperties(properties, cls);
string property1 = properties.getProperty("path.separator");
string str3 = properties.getProperty("platform.root");
if (str3 != null && !String.instancehelper_endsWith(str3, (string) File.separator))
str3 = new StringBuilder().append(str3).append((string) File.separator).toString();
string property2 = properties.getProperty("loader.preloadpath");
string property3 = properties.getProperty("loader.preload");
if (property2 != null && property3 != null)
{
string[] paths = String.instancehelper_split(property2, property1);
if (str3 != null)
{
for (int index = 0; index < paths.Length; ++index)
{
File.__\u003Cclinit\u003E();
if (!new File(paths[index]).isAbsolute())
paths[index] = new StringBuilder().append(str3).append(paths[index]).toString();
}
}
Loader.preload(paths, String.instancehelper_split(property3, property1));
}
File file = (File) null;
string libraryName;
string str4;
string str5;
UnsatisfiedLinkError unsatisfiedLinkError1;
IOException ioException1;
// ISSUE: fault handler
try
{
try
{
libraryName = Loader.getLibraryName(cls);
string prefix = new StringBuilder().append(properties.getProperty("library.prefix")).append(libraryName).toString();
string property4 = properties.getProperty("library.suffix");
string name = new StringBuilder().append(properties.getProperty("platform.name")).append('/').append(prefix).append(property4).toString();
file = Loader.extractResource(cls, name, (File) null, prefix, property4);
if (file != null)
{
str4 = file.getAbsolutePath();
System.load(str4, Loader.__\u003CGetCallerID\u003E());
Loader.loadedLibraries.put((object) cls, (object) str4);
str5 = str4;
goto label_31;
}
else
goto label_34;
}
catch (Exception ex)
{
int num2 = 0;
M0 m0 = ByteCodeHelper.MapException<UnsatisfiedLinkError>(ex, (ByteCodeHelper.MapFlags) num2);
if (m0 == null)
throw;
else
unsatisfiedLinkError1 = (UnsatisfiedLinkError) m0;
}
}
catch (IOException ex)
{
int num2 = 1;
ioException1 = (IOException) ByteCodeHelper.MapException<IOException>((Exception) ex, (ByteCodeHelper.MapFlags) num2);
goto label_30;
}
__fault
{
if (file != null)
file.deleteOnExit();
}
UnsatisfiedLinkError unsatisfiedLinkError2 = unsatisfiedLinkError1;
goto label_47;
label_30:
//.........这里部分代码省略.........
示例9: 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());
//.........这里部分代码省略.........
示例10: createContext
public static LogContext createContext(Class context)
{
return Log.createContext(context.getName());
}