首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏游戏杂谈

    emoji表情引发的JNI崩溃

    "([BLjava/lang/String;IIII)V"))     {         CCLOG("%s %d: error to get methodInfo", __FILE__, __LINE ->NewByteArray(strLen);     methodInfo.env->SetByteArrayRegion(byteArray, 0, strLen, reinterpret_cast jstrFont = methodInfo.env->NewStringUTF(pFontName);     methodInfo.env->CallStaticVoidMethod(methodInfo.classID methodInfo.env->DeleteLocalRef(jstrText);     methodInfo.env->DeleteLocalRef(byteArray);     methodInfo.env ->DeleteLocalRef(jstrFont);     methodInfo.env->DeleteLocalRef(methodInfo.classID);     return true;

    2K30发布于 2018-11-20
  • 来自专栏程序员开发工具

    注解使用入门(一)

    通过 @interface 定义,注解名即为自定义注解名,这里注解名为MethodInfo (2). 注解配置参数名为注解类的方法名,且: a. annotation = (MethodInfo) constructor .getAnnotation(MethodInfo.class); getAnnotations methodInfo = (MethodInfo) annotation } isAnnotationPresent(AnnotationName.class) 表示该 Target 是否被某个 Annotation ); if (hasAnnotation) { /* * 根据注解类型返回方法的指定类型注解 */ MethodInfo annotation = (MethodInfo annotation = (MethodInfo) constructor .getAnnotation(MethodInfo.class);

    47210发布于 2018-09-18
  • 来自专栏全栈程序员必看

    c# 反射调用

    methodInfo = type.GetMethod("Test1"); methodInfo.Invoke(oReflection, null);//调用方法 methodInfo = type.GetMethod("Test2"); methodInfo.Invoke(oReflection, new object[] { , null);//调用方法 } 静态方法调用 MethodInfo methodInfo = type.GetMethod("Test5"); methodInfo.Invoke (oReflection, new object[] { "123" });//调用方法 MethodInfo methodInfo = type.GetMethod("Test5"); methodInfo.Invoke methodInfo.Invoke(oReflection, new object[] { "123" }); 反射调用普通类中的泛型方法 MethodInfo methodGeneric = methodInfo.MakeGenericMethod

    1.2K10编辑于 2022-07-13
  • 来自专栏跟着阿笨一起玩NET

    推荐一个快速反射调用的类

    methodInfo)         {             DynamicMethod dynamicMethod =new DynamicMethod(string.Empty, typeof (object), new Type[] { typeof(object), typeof(object[]) }, methodInfo.DeclaringType.Module);             methodInfo.IsStatic)             {                 il.Emit(OpCodes.Ldarg_0);             }             (OpCodes.Callvirt, methodInfo, null);             if (methodInfo.ReturnType ==typeof(void))                 il.Emit(OpCodes.Ldnull);             else                 EmitBoxIfNeeded(il, methodInfo.ReturnType);

    69820发布于 2018-09-18
  • 来自专栏明丰随笔

    浅谈.Net反射 11

    GetMethod(string name) public MethodInfo GetMethod(string name, Type[] types) public MethodInfo[] GetMethods GetMethod public virtual MethodInfo SetMethod public bool IsSpecialName public override MemberTypes (bool nonPublic); public MethodInfo GetGetMethod() public abstract MethodInfo GetSetMethod(bool nonPublic () public virtual MethodInfo MakeGenericMethod(params Type[] typeArguments) 分析ParameterInfo类。 public override MemberTypes MemberType public virtual MethodInfo RemoveMethod public abstract MethodInfo

    52520发布于 2019-07-30
  • 来自专栏大内老A

    Dora.Interception,为.NET Core度身打造的AOP框架 [5]:轻松地实现与其他AOP框架的整合

    public sealed class InterceptorDecoration { public InterceptorDelegate GetInterceptor(MethodInfo methodInfo); public MethodInfo GetTargetMethod(MethodInfo methodInfo); public bool IsInterceptable (MethodInfo methodInfo); public IReadOnlyDictionary<int, InterceptorDelegate> Interceptors { get ; } public bool IsEmpty { get; } public IReadOnlyDictionary<MethodInfo, MethodBasedInterceptorDecoration class MethodBasedInterceptorDecoration { public InterceptorDelegate Interceptor { get; } public MethodInfo

    54530发布于 2018-12-18
  • 来自专栏明丰随笔

    浅谈.Net反射 8

    方法信息与MethodInfo类型 System.Reflection.MethodInfo类封装了类型的方法信息,它继承自MemberInfo。 sb.AppendLine("Explore type " + t.Name + " methods:"); sb.AppendLine(String.Empty.PadLeft(50, '-')); MethodInfo [] methods = t.GetMethods(); foreach (MethodInfo method in methods) { sb.AppendLine("name:" + parameter HasDefaultValue: " + param.HasDefaultValue); } } Console.WriteLine(sb.ToString()); } MethodInfo 与前面不同的是,MethodInfo可以具有参数和返回值,MethodInfo类提供了GetParameters()方法获取参数对象的数组,方法的参数都封装在了ParameterInfo类型中。

    52650发布于 2019-07-30
  • 来自专栏大内老A

    调用内部或私有方法的N种方法

    ; } } 二、MethodInfo.CreateDelegate方法 要获得Foobar对象的InternalValue属性值(int类型),实际上需要一个Func<Foobar,int>类型的委托 由于返回值实际上是通过InternalValue属性的Get方法获得的,而表示方法的MethodInfo类型具有一个CreateDelegate<TDelegate>方法,我们可以采用如下的方式利用InternalValue CreateDelegate())(foobar); private static Func<Foobar, int> CreateDelegate() { var methodInfo ; return methodInfo.CreateDelegate<Func<Foobar, int>>(); } } 三、表达式(树) 一般来说,所有的反射解决方案都可以转换成基于表达式 CreateDelegate())(foobar); private static Func<Foobar, int> CreateDelegate() { var methodInfo

    83120编辑于 2023-07-21
  • 来自专栏痴者工良

    C#反射与特性(五):类型成员操作

    methodObj = typeObj.GetMethod("ToString"); MethodInfo methodFather = typeFather.GetMethod ("ToString"); MethodInfo methodSon = typeSon.GetMethod("ToString"); MethodInfo 方法 使用说明 GetSetMethod 获取 set 方法,返回 MethodInfo GetGetMethod 获取 get 方法,返回 MethodInfo GetAccessors 获取上面两个方法的集合 set = property.GetSetMethod(); MethodInfo get = property.GetGetMethod(); MethodInfo 这里不再赘述 3.1.3 获取重载方法 在 《C# 反射与特性》系列的第四篇,我们介绍了构造函数 ConstructorInfo 的调用和重载,MethodInfo 实际上也是差不多的。

    1.4K40发布于 2021-04-26
  • 来自专栏pangguoming

    Java Annotation 及几个常用开源项目注解原理简析

    的示例,MethodInfo Annotation 作用为给方法添加相关信息,包括 author、date、version 2 定义 Java 1 2 3 4 5 6 7 8 9 10 11 12 methodInfo = method.getAnnotation( MethodInfo.class);             if (methodInfo ! ("method date:" + methodInfo.date());             }         }     } catch (ClassNotFoundException e) {         e.printStackTrace();     } } 以之前自定义的 MethodInfo 为例,利用 Target(这里是 Method)getAnnotation 函数得到 methodInfo = element.getAnnotation(MethodInfo.class);                 map.put(element.getEnclosingElement

    1.3K50发布于 2018-03-08
  • 来自专栏张善友的专栏

    ASP.NET MVC Preview生命周期分析

    protected internal virtual void InvokeActionMethod(MethodInfo methodInfo, RouteValueDictionary values memberChain.Push(methodInfo);              MethodInfo baseMethod = methodInfo.GetBaseDefinition(); protected internal virtual void InvokeActionMethod(MethodInfo methodInfo, RouteValueDictionary values ) {      if (methodInfo == null) {          throw new ArgumentNullException("methodInfo");      } InvokeActionMethodFilters(methodInfo, () => methodInfo.Invoke(this, parameterValues)); 这行代码将 Action

    1.8K70发布于 2018-01-30
  • 来自专栏liulun

    SilverLight企业应用框架设计【三】服务端设计

    WCFRouteTable { static Dictionary<string, Type> routeService; static Dictionary<string, MethodInfo methodInfo) { this.m_execute = this.GetExecuteDelegate(methodInfo); } methodInfo) { ParameterExpression instanceParameter = Expression.Parameter(typeof ); Expression instanceCast = methodInfo.IsStatic ? null : instanceE; MethodCallExpression methodCall = Expression.Call(instanceCast, methodInfo

    40240编辑于 2022-05-09
  • 来自专栏大内老A

    全新升级的AOP框架Dora.Interception[5]: 实现任意的拦截器注册方式

    public interface IInterceptorProvider { bool CanIntercept(Type targetType, MethodInfo method, out bool suppressed); IEnumerable<Sortable<InvokeDelegate>> GetInterceptors(Type targetType, MethodInfo method); void Validate(Type targetType, Action<MethodInfo> methodValidator, Action<PropertyInfo> ConditionalInterceptorRegistration对象的集合,而每一个ConditionalInterceptorRegistration对象是一个表示匹配条件的Func<Type, MethodInfo ; } public override IEnumerable<Sortable<InvokeDelegate>> GetInterceptors(Type targetType, MethodInfo

    51620编辑于 2022-06-28
  • 来自专栏大内老A

    ASP.NET MVC三个重要的描述对象:ActionDescriptor

    methodInfo, string actionName, ControllerDescriptor controllerDescriptor); 4: 5: ReflectedControllerDescriptor重写了UniqueId属性,在现有的基础上将表示Action方法的MethodInfo对象作为了决定元素之一。 Execute方法最终传入参数列表调用MethodInfo对象执行Action方法。 如下面的代码片断所示,ReflectedAsyncActionDescriptor的构造的参数asyncMethodInfo和completedMethodInfo就代码这两个MethodInfo。 在构造函数中初始化的这两个MethodInfo对象爱分别通过只读属性AsyncMethodInfo和CompletedMethodInfo返回。

    1K70发布于 2018-01-15
  • 来自专栏IT民工的代码世界

    ORM设计思想——智能识别更新字段与日志AOP追踪记录

    = null) { var methodInfo = args.MethodCall.MethodBase as MethodInfo; = null) { var methodInfo = args.MethodCall.MethodBase as MethodInfo; if (_filter(methodInfo)) { AfterExecute(this, args); = null) { var methodInfo = args.MethodCall.MethodBase as MethodInfo; if (_filter(methodInfo)) { AfterExecute(this, args);

    52620编辑于 2023-07-19
  • 来自专栏全栈文档库

    C#进阶-反射的详解与应用

    然后,使用Type对象的GetMethod方法获取Add方法的MethodInfo对象。最后,我们使用MethodInfo对象的Invoke方法动态地调用Add方法,并传入参数。 然后,通过使用typeof(Calculator)获得Calculator类型的Type对象,我们利用GetMethod获取名为Add的方法的MethodInfo对象。 然后,我们使用GetMethod方法并配合BindingFlags.NonPublic | BindingFlags.Instance参数来获取私有方法的MethodInfo对象。 使用反射调用特定的重载版本时,可以通过指定参数类型来获取正确的MethodInfo对象。 methodInfo = calcType.GetMethod("Add", paramTypes); // 调用重载方法 var result = methodInfo.Invoke

    79742编辑于 2024-03-27
  • 来自专栏hbbliyong

    C#动态调用泛型类、泛型方法

    对于非静态方法:public void DoWork<T>()           对于非静态方法,调用MethodInfo.Invoke(object, object[])时,第一个参数需要指明泛型方法的所有者 new Worker(); //Get type of Worker Type workerType = typeof(Worker); //Get Generic Method MethodInfo curType.IsAbstract)//Filter BaseEntity { MethodInfo curMethod = doWorkMethod.MakeGenericMethod curType.IsAbstract) { MethodInfo curMethod = staticDoWorkMethod.MakeGenericMethod(curType Member method 16 17 Console.WriteLine(">>>>>>>>>Use Generic Method:"); 18 MethodInfo

    3.6K20发布于 2018-12-28
  • 来自专栏明志德到的IT笔记

    C# 反射

    oTest, new object[] { "一生为你" }); } { MethodInfo new object[] { 234, "心欲无痕" }); } { MethodInfo , new object[] { "PHS", 345 }); } { MethodInfo object[] { "张中魁" });//静态方法实例可以要 } { MethodInfo // Console.WriteLine(item.Name); //} MethodInfo

    42120编辑于 2023-10-21
  • 来自专栏CodeGuide | 程序员编码指南

    字节码编程,Javassist篇五《使用Bytecode指令码生成含有自定义注解的类和方法》

    读取方法指令码 MethodInfo methodInfo = ctMethod.getMethodInfo(); CodeAttribute codeAttribute = methodInfo.getCodeAttribute 通过指令修改方法 ConstPool cp = methodInfo.getConstPool(); Bytecode bytecode = new Bytecode(cp); bytecode.addDconst (0); bytecode.addReturn(CtClass.doubleType); methodInfo.setCodeAttribute(bytecode.toCodeAttribute()); new CtClass[]{pool.get(String.class.getName())}, ctClass); mainMethod.setModifiers(Modifier.PUBLIC); MethodInfo methodInfo = mainMethod.getMethodInfo(); ConstPool cp = methodInfo.getConstPool(); 创建类和方法的信息在我们几个章节中也经常使用

    1.2K41发布于 2020-04-30
  • 来自专栏林德熙的博客

    定制 MSTest 单元测试框架 让一个 TestMethod 包含多个测试用例

    []> GetData(MethodInfo methodInfo) { // 返回单元测试方法的所有测试用例,将测试用例当成数据 } public string GetDisplayName(MethodInfo methodInfo, object?[]? 在 ITestDataSource 的 GetData 里面,传入的参数是 MethodInfo methodInfo 表示当前的测试方法。 []> GetData(MethodInfo methodInfo) { if (! GetDisplayName(MethodInfo methodInfo, object?[]?

    21200编辑于 2025-07-20
领券