本文整理汇总了C#中TypeWrapper.GetFieldWrapper方法的典型用法代码示例。如果您正苦于以下问题:C# TypeWrapper.GetFieldWrapper方法的具体用法?C# TypeWrapper.GetFieldWrapper怎么用?C# TypeWrapper.GetFieldWrapper使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TypeWrapper
的用法示例。
在下文中一共展示了TypeWrapper.GetFieldWrapper方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProxyGenerator
static ProxyGenerator()
{
ClassLoaderWrapper bootClassLoader = ClassLoaderWrapper.GetBootstrapClassLoader();
proxyClass = bootClassLoader.LoadClassByDottedNameFast("java.lang.reflect.Proxy");
errorClass = bootClassLoader.LoadClassByDottedNameFast("java.lang.Error");
runtimeExceptionClass = bootClassLoader.LoadClassByDottedNameFast("java.lang.RuntimeException");
undeclaredThrowableExceptionConstructor = bootClassLoader.LoadClassByDottedNameFast("java.lang.reflect.UndeclaredThrowableException").GetMethodWrapper("<init>", "(Ljava.lang.Throwable;)V", false);
undeclaredThrowableExceptionConstructor.Link();
invocationHandlerField = proxyClass.GetFieldWrapper("h", "Ljava.lang.reflect.InvocationHandler;");
invocationHandlerField.Link();
javaLangReflectMethod = bootClassLoader.LoadClassByDottedNameFast("java.lang.reflect.Method");
javaLangNoSuchMethodException = bootClassLoader.LoadClassByDottedNameFast("java.lang.NoSuchMethodException");
javaLangNoClassDefFoundErrorConstructor = bootClassLoader.LoadClassByDottedNameFast("java.lang.NoClassDefFoundError").GetMethodWrapper("<init>", "(Ljava.lang.String;)V", false);
javaLangNoClassDefFoundErrorConstructor.Link();
javaLangThrowable_getMessage = bootClassLoader.LoadClassByDottedNameFast("java.lang.Throwable").GetMethodWrapper("getMessage", "()Ljava.lang.String;", false);
javaLangThrowable_getMessage.Link();
javaLangClass_getMethod = CoreClasses.java.lang.Class.Wrapper.GetMethodWrapper("getMethod", "(Ljava.lang.String;[Ljava.lang.Class;)Ljava.lang.reflect.Method;", false);
javaLangClass_getMethod.Link();
invocationHandlerClass = bootClassLoader.LoadClassByDottedNameFast("java.lang.reflect.InvocationHandler");
invokeMethod = invocationHandlerClass.GetMethodWrapper("invoke", "(Ljava.lang.Object;Ljava.lang.reflect.Method;[Ljava.lang.Object;)Ljava.lang.Object;", false);
proxyConstructor = proxyClass.GetMethodWrapper("<init>", "(Ljava.lang.reflect.InvocationHandler;)V", false);
proxyConstructor.Link();
hashCodeMethod = CoreClasses.java.lang.Object.Wrapper.GetMethodWrapper("hashCode", "()I", false);
equalsMethod = CoreClasses.java.lang.Object.Wrapper.GetMethodWrapper("equals", "(Ljava.lang.Object;)Z", false);
toStringMethod = CoreClasses.java.lang.Object.Wrapper.GetMethodWrapper("toString", "()Ljava.lang.String;", false);
}
示例2: Emit
internal static bool Emit(DynamicTypeWrapper.FinishContext context, TypeWrapper wrapper, CodeEmitter ilgen, ClassFile classFile, int i, ClassFile.Method.Instruction[] code, InstructionFlags[] flags)
{
if (i >= 3
&& (flags[i - 0] & InstructionFlags.BranchTarget) == 0
&& (flags[i - 1] & InstructionFlags.BranchTarget) == 0
&& (flags[i - 2] & InstructionFlags.BranchTarget) == 0
&& (flags[i - 3] & InstructionFlags.BranchTarget) == 0
&& code[i - 1].NormalizedOpCode == NormalizedByteCode.__ldc
&& code[i - 2].NormalizedOpCode == NormalizedByteCode.__ldc
&& code[i - 3].NormalizedOpCode == NormalizedByteCode.__ldc)
{
// we now have a structural match, now we need to make sure that the argument values are what we expect
TypeWrapper tclass = classFile.GetConstantPoolClassType(code[i - 3].Arg1);
TypeWrapper vclass = classFile.GetConstantPoolClassType(code[i - 2].Arg1);
string fieldName = classFile.GetConstantPoolConstantString(code[i - 1].Arg1);
if (tclass == wrapper && !vclass.IsUnloadable && !vclass.IsPrimitive && !vclass.IsNonPrimitiveValueType)
{
FieldWrapper field = wrapper.GetFieldWrapper(fieldName, vclass.SigName);
if (field != null && !field.IsStatic && field.IsVolatile && field.DeclaringType == wrapper && field.FieldTypeWrapper == vclass)
{
// everything matches up, now call the actual emitter
DoEmit(context, wrapper, ilgen, field);
return true;
}
}
}
return false;
}
示例3: GetFieldImpl
private static FieldWrapper GetFieldImpl(TypeWrapper tw, string name, string sig)
{
for(;;)
{
FieldWrapper fw = tw.GetFieldWrapper(name, sig);
if(fw == null || !fw.IsHideFromReflection)
{
return fw;
}
tw = fw.DeclaringType.BaseTypeWrapper;
if(tw == null)
{
return null;
}
}
}