本文整理汇总了C#中TypeWrapper.GetMethodWrapper方法的典型用法代码示例。如果您正苦于以下问题:C# TypeWrapper.GetMethodWrapper方法的具体用法?C# TypeWrapper.GetMethodWrapper怎么用?C# TypeWrapper.GetMethodWrapper使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TypeWrapper
的用法示例。
在下文中一共展示了TypeWrapper.GetMethodWrapper方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: Boxer
static Boxer()
{
ClassLoaderWrapper bootClassLoader = ClassLoaderWrapper.GetBootstrapClassLoader();
javaLangByte = bootClassLoader.LoadClassByDottedNameFast("java.lang.Byte");
byteValue = javaLangByte.GetMethodWrapper("byteValue", "()B", false);
byteValue.Link();
valueOfByte = javaLangByte.GetMethodWrapper("valueOf", "(B)Ljava.lang.Byte;", false);
valueOfByte.Link();
javaLangBoolean = bootClassLoader.LoadClassByDottedNameFast("java.lang.Boolean");
booleanValue = javaLangBoolean.GetMethodWrapper("booleanValue", "()Z", false);
booleanValue.Link();
valueOfBoolean = javaLangBoolean.GetMethodWrapper("valueOf", "(Z)Ljava.lang.Boolean;", false);
valueOfBoolean.Link();
javaLangShort = bootClassLoader.LoadClassByDottedNameFast("java.lang.Short");
shortValue = javaLangShort.GetMethodWrapper("shortValue", "()S", false);
shortValue.Link();
valueOfShort = javaLangShort.GetMethodWrapper("valueOf", "(S)Ljava.lang.Short;", false);
valueOfShort.Link();
javaLangCharacter = bootClassLoader.LoadClassByDottedNameFast("java.lang.Character");
charValue = javaLangCharacter.GetMethodWrapper("charValue", "()C", false);
charValue.Link();
valueOfCharacter = javaLangCharacter.GetMethodWrapper("valueOf", "(C)Ljava.lang.Character;", false);
valueOfCharacter.Link();
javaLangInteger = bootClassLoader.LoadClassByDottedNameFast("java.lang.Integer");
intValue = javaLangInteger.GetMethodWrapper("intValue", "()I", false);
intValue.Link();
valueOfInteger = javaLangInteger.GetMethodWrapper("valueOf", "(I)Ljava.lang.Integer;", false);
valueOfInteger.Link();
javaLangFloat = bootClassLoader.LoadClassByDottedNameFast("java.lang.Float");
floatValue = javaLangFloat.GetMethodWrapper("floatValue", "()F", false);
floatValue.Link();
valueOfFloat = javaLangFloat.GetMethodWrapper("valueOf", "(F)Ljava.lang.Float;", false);
valueOfFloat.Link();
javaLangLong = bootClassLoader.LoadClassByDottedNameFast("java.lang.Long");
longValue = javaLangLong.GetMethodWrapper("longValue", "()J", false);
longValue.Link();
valueOfLong = javaLangLong.GetMethodWrapper("valueOf", "(J)Ljava.lang.Long;", false);
valueOfLong.Link();
javaLangDouble = bootClassLoader.LoadClassByDottedNameFast("java.lang.Double");
doubleValue = javaLangDouble.GetMethodWrapper("doubleValue", "()D", false);
doubleValue.Link();
valueOfDouble = javaLangDouble.GetMethodWrapper("valueOf", "(D)Ljava.lang.Double;", false);
valueOfDouble.Link();
}
示例3: IsSafeForAutomagicSerialization
private static bool IsSafeForAutomagicSerialization(TypeWrapper wrapper)
{
if (wrapper.TypeAsBaseType.IsSerializable)
{
return false;
}
if (wrapper.IsSubTypeOf(iserializable))
{
return false;
}
if (wrapper.IsSubTypeOf(iobjectreference))
{
return false;
}
if (wrapper.GetMethodWrapper("GetObjectData", "(Lcli.System.Runtime.Serialization.SerializationInfo;Lcli.System.Runtime.Serialization.StreamingContext;)V", false) != null)
{
return false;
}
if (wrapper.GetMethodWrapper("<init>", "(Lcli.System.Runtime.Serialization.SerializationInfo;Lcli.System.Runtime.Serialization.StreamingContext;)V", false) != null)
{
return false;
}
return true;
}
示例4: GetMethodImpl
private static MethodWrapper GetMethodImpl(TypeWrapper tw, string name, string sig)
{
for(;;)
{
MethodWrapper mw = tw.GetMethodWrapper(name, sig, true);
if(mw == null || !mw.IsHideFromReflection)
{
return mw;
}
tw = mw.DeclaringType.BaseTypeWrapper;
if(tw == null)
{
return null;
}
}
}
示例5: GetInterfaceMethod
private static MethodWrapper GetInterfaceMethod(TypeWrapper wrapper, string name, string sig)
{
MethodWrapper method = wrapper.GetMethodWrapper(name, sig, false);
if(method != null)
{
return method;
}
TypeWrapper[] interfaces = wrapper.Interfaces;
for(int i = 0; i < interfaces.Length; i++)
{
method = GetInterfaceMethod(interfaces[i], name, sig);
if(method != null)
{
return method;
}
}
return null;
}
示例6: AddAutomagicSerialization
internal static ConstructorInfo AddAutomagicSerialization(TypeWrapper wrapper)
{
ConstructorInfo serializationCtor = null;
if (wrapper.GetClassLoader().NoAutomagicSerialization)
{
// do nothing
}
else if ((wrapper.Modifiers & IKVM.Attributes.Modifiers.Enum) != 0)
{
MarkSerializable(wrapper);
}
else if (wrapper.IsSubTypeOf(serializable) && IsSafeForAutomagicSerialization(wrapper))
{
if (wrapper.IsSubTypeOf(externalizable))
{
MethodWrapper ctor = wrapper.GetMethodWrapper("<init>", "()V", false);
if (ctor != null && ctor.IsPublic)
{
MarkSerializable(wrapper);
ctor.Link();
serializationCtor = AddConstructor(wrapper.TypeAsBuilder, ctor, null, true);
if (!wrapper.BaseTypeWrapper.IsSubTypeOf(serializable))
{
AddGetObjectData(wrapper);
}
if (wrapper.BaseTypeWrapper.GetMethodWrapper("readResolve", "()Ljava.lang.Object;", true) != null)
{
RemoveReadResolve(wrapper);
}
}
}
else if (wrapper.BaseTypeWrapper.IsSubTypeOf(serializable))
{
ConstructorInfo baseCtor = wrapper.GetBaseSerializationConstructor();
if (baseCtor != null && (baseCtor.IsFamily || baseCtor.IsFamilyOrAssembly))
{
MarkSerializable(wrapper);
serializationCtor = AddConstructor(wrapper.TypeAsBuilder, null, baseCtor, false);
AddReadResolve(wrapper);
}
}
else
{
MethodWrapper baseCtor = wrapper.BaseTypeWrapper.GetMethodWrapper("<init>", "()V", false);
if (baseCtor != null && baseCtor.IsAccessibleFrom(wrapper.BaseTypeWrapper, wrapper, wrapper))
{
MarkSerializable(wrapper);
AddGetObjectData(wrapper);
#if STATIC_COMPILER
// because the base type can be a __WorkaroundBaseClass__, we may need to replace the constructor
baseCtor = ((AotTypeWrapper)wrapper).ReplaceMethodWrapper(baseCtor);
#endif
baseCtor.Link();
serializationCtor = AddConstructor(wrapper.TypeAsBuilder, baseCtor, null, true);
AddReadResolve(wrapper);
}
}
}
return serializationCtor;
}
示例7: AddReadResolve
private static void AddReadResolve(TypeWrapper wrapper)
{
MethodWrapper mw = wrapper.GetMethodWrapper("readResolve", "()Ljava.lang.Object;", false);
if (mw != null && !wrapper.IsSubTypeOf(iobjectreference))
{
TypeBuilder tb = wrapper.TypeAsBuilder;
tb.AddInterfaceImplementation(JVM.Import(typeof(IObjectReference)));
MethodBuilder getRealObject = tb.DefineMethod("IObjectReference.GetRealObject", MethodAttributes.Private | MethodAttributes.Virtual | MethodAttributes.NewSlot | MethodAttributes.Final,
Types.Object, new Type[] { JVM.Import(typeof(StreamingContext)) });
getRealObject.SetCustomAttribute(securityCriticalAttribute);
AttributeHelper.HideFromJava(getRealObject);
tb.DefineMethodOverride(getRealObject, JVM.Import(typeof(IObjectReference)).GetMethod("GetRealObject"));
CodeEmitter ilgen = CodeEmitter.Create(getRealObject);
mw.Link();
ilgen.Emit(OpCodes.Ldarg_0);
mw.EmitCall(ilgen);
ilgen.Emit(OpCodes.Ret);
}
}