本文整理汇总了C#中java.lang.Class.getDeclaredField方法的典型用法代码示例。如果您正苦于以下问题:C# Class.getDeclaredField方法的具体用法?C# Class.getDeclaredField怎么用?C# Class.getDeclaredField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.lang.Class
的用法示例。
在下文中一共展示了Class.getDeclaredField方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: registerWidget
public static void registerWidget(Class clazz)
{
if (Modifier.isAbstract(clazz.getModifiers()))
return;
DataType[] dataTypeArray1 = (DataType[]) null;
SecurityException securityException;
try
{
try
{
try
{
try
{
try
{
Field declaredField = clazz.getDeclaredField("TYPES", DisplayElementRegistry.__\u003CGetCallerID\u003E());
int modifiers = declaredField.getModifiers();
if (!Modifier.isStatic(modifiers))
{
string str = "TYPES must be static";
Throwable.__\u003CsuppressFillInStackTrace\u003E();
throw new RuntimeException(str);
}
else if (!Modifier.isFinal(modifiers))
{
string str = "TYPES must be final";
Throwable.__\u003CsuppressFillInStackTrace\u003E();
throw new RuntimeException(str);
}
else
{
dataTypeArray1 = (DataType[]) declaredField.get((object) null, DisplayElementRegistry.__\u003CGetCallerID\u003E());
DisplayElementRegistry.declaredTypes.put((object) clazz, (object) dataTypeArray1);
goto label_22;
}
}
catch (IllegalArgumentException ex)
{
}
}
catch (IllegalAccessException ex)
{
goto label_15;
}
}
catch (NoSuchFieldException ex)
{
goto label_16;
}
}
catch (SecurityException ex)
{
int num = 1;
securityException = (SecurityException) ByteCodeHelper.MapException<SecurityException>((Exception) ex, (ByteCodeHelper.MapFlags) num);
goto label_17;
}
}
catch (Exception ex)
{
int num = 2;
if (ByteCodeHelper.MapException<ClassCastException>(ex, (ByteCodeHelper.MapFlags) num) == null)
throw;
else
goto label_18;
}
if (!DisplayElementRegistry.\u0024assertionsDisabled)
{
Throwable.__\u003CsuppressFillInStackTrace\u003E();
throw new AssertionError();
}
else
goto label_22;
label_15:
string str1 = "TYPES must be public";
Throwable.__\u003CsuppressFillInStackTrace\u003E();
throw new RuntimeException(str1);
label_16:
string str2 = "Every ValueBasedDisplayElement must have a TYPES static field of type DataType[]";
Throwable.__\u003CsuppressFillInStackTrace\u003E();
throw new RuntimeException(str2);
label_17:
Throwable.instancehelper_printStackTrace((Exception) securityException);
return;
label_18:
string str3 = "TYPES must be of type Type[]";
Throwable.__\u003CsuppressFillInStackTrace\u003E();
throw new RuntimeException(str3);
label_22:
if (dataTypeArray1 == null)
{
string str4 = "TYPES must not be null";
Throwable.__\u003CsuppressFillInStackTrace\u003E();
throw new RuntimeException(str4);
}
else
{
DataType[] dataTypeArray2 = dataTypeArray1;
int length = dataTypeArray2.Length;
for (int index = 0; index < length; ++index)
//.........这里部分代码省略.........
示例2: getName
public static string getName(Class clazz)
{
string str1;
try
{
Field declaredField = clazz.getDeclaredField("NAME", DisplayElement.__\u003CGetCallerID\u003E());
int modifiers = declaredField.getModifiers();
if (!Modifier.isStatic(modifiers))
{
string str2 = "TYPES must be static";
Throwable.__\u003CsuppressFillInStackTrace\u003E();
throw new RuntimeException(str2);
}
else if (!Modifier.isFinal(modifiers))
{
string str2 = "TYPES must be final";
Throwable.__\u003CsuppressFillInStackTrace\u003E();
throw new RuntimeException(str2);
}
else if (Modifier.isStatic(modifiers))
{
if (Modifier.isFinal(modifiers))
str1 = (string) declaredField.get((object) null, DisplayElement.__\u003CGetCallerID\u003E());
else
goto label_11;
}
else
goto label_11;
}
catch (Exception ex)
{
int num = 2;
if (ByteCodeHelper.MapException<Exception>(ex, (ByteCodeHelper.MapFlags) num) == null)
throw;
else
goto label_10;
}
return str1;
label_10:
label_11:
return clazz.getSimpleName();
}