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

    解读WPF中的Xaml

    > methodBaseList = new List<MethodBase>(constructors.Length); Type[] argumentTypes = new ) constructors[index]); } MethodBase[] methodBaseArray = new MethodBase[methodBaseList.Count = null && methodBaseArray.Length == 0) methodBaseArray = (MethodBase[]) null; methodBase; try { methodBase = binder.BindToMethod(bindingAttr = (MethodBase) null; } if (methodBase == (MethodBase) null) {

    2.1K20编辑于 2022-12-07
  • 来自专栏蘑菇先生的技术笔记

    日志系统实战(一)—AOP静态注入

    : Attribute { } public class Log : WeaveAction { public static void OnActionBefore(MethodBase 方法引用 var mfReference=assembly.MainModule.Import(typeof (System.Reflection.MethodBase maxstack 1 .locals init ( [0] string str) L_0000: call class [mscorlib]System.Reflection.MethodBase [mscorlib]System.Reflection.MethodBase::GetCurrentMethod() L_0005: call void TestLibrary.Log::OnActionBefore (class [mscorlib]System.Reflection.MethodBase) L_000a: nop L_000b: ldstr "Vidar" L_0010:

    1.2K40发布于 2018-05-21
  • 来自专栏DotNet NB && CloudNative

    一个.NET开源、轻量级的运行耗时统计库 - MethodTimer

    summary> public static class MethodTimeLogger1 { public static void Log(MethodBase methodBase, long milliseconds, string message) { Console.WriteLine($"方法: {methodBase.Name} 耗时:{milliseconds} 毫秒,信息:{message}"); } } 运行耗时为TimeSpan: methodBase, TimeSpan elapsed, string message) { Console.WriteLine($"方法:{ methodBase.Name} 耗时:{elapsed.TotalMilliseconds} 毫秒,信息:{message}"); } } 耗时统计时长输出

    27110编辑于 2024-11-26
  • 来自专栏开源项目

    一个.NET开源、轻量级的运行耗时统计库 - MethodTimer

    $"输出结果{i}");   }  }  finally  {   stopwatch.Stop();   string message = null;   MethodTimeLogger.Log(MethodBase.GetMethodFromHandle          public static class MethodTimeLogger1        {            public static void Log(MethodBase  methodBase, long milliseconds, string message)            {                Console.WriteLine($"方法:{methodBase.Name /         public static class MethodTimeLogger        {            public static void Log(MethodBase  methodBase, TimeSpan elapsed, string message)            {                Console.WriteLine($"方法:{methodBase.Name

    26210编辑于 2024-10-31
  • 来自专栏小特工作室

    基于微软企业库的AOP组件(含源码)

    { //增加其他日志类型,处理方案如下 //无论是否需记录log_method方法,方法均先执行完成.同时,记录时执行时间 MethodBase mbCurrent = input.MethodBase; string methodName = input.MethodBase.Name; string = null ) { string declaringType = input.MethodBase.ToString(); string instanceName = input.MethodBase.Module.Name; //获取参数列表 Dictionary for (int u = 0; u < sfs.Length; ++u) { System.Reflection.MethodBase

    72370发布于 2018-02-01
  • 来自专栏张志敏的技术专栏

    Activity 生命周期及其栈管理方式

    ." + MethodBase.GetCurrentMethod().Name); } protected override void OnStart() { base.OnStart(); Android.Util.Log.Debug("Debug", this.GetType().Name + "." + MethodBase.GetCurrentMethod().Name); } void OnResume() { base.OnResume(); Android.Util.Log.Debug("Debug", this.GetType().Name + "." + MethodBase.GetCurrentMethod void OnRestart() { base.OnRestart(); Android.Util.Log.Debug("Debug", this.GetType().Name + "." + MethodBase.GetCurrentMethod void OnDestroy() { base.OnDestroy(); Android.Util.Log.Debug("Debug", this.GetType().Name + "." + MethodBase.GetCurrentMethod

    1.4K20发布于 2020-08-10
  • 来自专栏科控自动化

    [C#] 利用MethodTimer.Fody 统计代码执行时间

    private static NLog.Logger _logger = NLog.LogManager.GetCurrentClassLogger(); public static void Log(MethodBase methodBase, TimeSpan elapsed, string message) { _logger.Debug($"{methodBase.Name}, {elapsed

    63521编辑于 2023-10-06
  • 来自专栏C#

    C#中的委托解析

    (_methodBase is MethodInfo)) { IRuntimeMethodInfo method = FindMethodHandle .ParameterType; } } } _methodBase } else if (IsUnmanagedFunctionPtr()) { if ((_methodBase (_methodBase is MethodInfo)) { IRuntimeMethodInfo method = FindMethodHandle declaringType = reflectedType; } _methodBase

    2.2K90发布于 2018-01-04
  • 来自专栏walterlv - 吕毅的博客

    C#/.NET 当我们在写事件 += 和 -= 的时候,方法是如何转换成事件处理器的

    through method handle check } // method ptrs don't match, go down long path // if (_methodBase _methodBase == null || !(_methodBase is MethodInfo) || !(d. _methodBase is MethodInfo)) return Delegate.InternalEqualMethodHandles(this, d); else return _methodBase.Equals(d. _methodBase); } 于是可以看出来,判断相等就是两个关键对象的判断相等: 方法所在的对象 方法信息(对应到反射里的 MethodInfo) 继续回到这段代码: 1 2 3 4 5 6 7

    74030编辑于 2023-10-22
  • 来自专栏听雨堂

    【5】基于Log4Net的日志系统

    有多种方法可以获取Logger对象,经过实验,使用下面的方法可以适用于普通类和静态类的输出: log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod { (new Thread(test)).Start(); } } void test() { log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod info); } public static void Info(String info) { log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod info); } public static void Error(String info) { log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod info); } public static void Fatal(String info) { log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod

    2K60发布于 2018-01-23
  • 来自专栏林德熙的博客

    dotnet 动态代理魔法书

    callMessageWrapper = new MethodCallMessageWrapper((IMethodCallMessage) msg); MethodInfo methodBase = callMessageWrapper.MethodBase as MethodInfo; if (methodBase == null) argumentTypeList = Type.EmptyTypes; } var method = type.GetMethod(methodBase.Name (method == null) { throw new ArgumentException("调用方法不匹配,找不到" + methodBase

    51720发布于 2019-06-15
  • 来自专栏痴者工良

    浅入 ABP 系列(4):事件总线

    param> /// <param name="method"></param> public CustomerExceptionEvent(Exception ex, MethodBase param name="method"></param> public CustomerExceptionEvent(Exception ex, string actionRoute, MethodBase summary> /// 当前出现位置 /// <example> /// /// MethodInfo = (MethodInfo)MethodBase.GetCurrentMethod new CustomerExceptionEvent(ex, MethodBase.GetCurrentMethod()); ... } MethodBase.GetCurrentMethod

    1.3K20发布于 2021-04-26
  • 来自专栏大内老A

    Enterprise Library Policy Injection Application Block 之二: PIAB设计和实现原理

    而对Target object的调用实际上是通过Reflection的方式调用的(callMessage.MethodBase.Invoke)。 public class InterceptingRealProxy : RealProxy, IRemotingTypeInfo 2: { 3: private Dictionary<MethodBase Target { get; } 13: public string TypeName { get; set; } 14: } 上面是它所有的成员定义,其中memberHandlers是一个以MethodBase )) 6: { 7: pipeline = this.memberHandlers[callMessage.MethodBase]; 8: } 9 总的来说上面的Code现根据msg解析出MethodBase,再获取对应的CallHandler Pipeline,最后调用Pipeline。

    67570发布于 2018-01-16
  • 来自专栏IT民工的代码世界

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

    } } object o = callMsg.MethodBase.Invoke = null) { var methodInfo = args.MethodCall.MethodBase as MethodInfo; = null) { var methodInfo = args.MethodCall.MethodBase as MethodInfo; = null) { var methodInfo = args.MethodCall.MethodBase as MethodInfo; { var methodCall = msg as IMethodCallMessage; var methodInfo = methodCall.MethodBase

    55120编辑于 2023-07-19
  • 来自专栏听雨堂

    异步方式访问网页

    reader.ReadToEnd();             reader.Close();         }         log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod content.Length.ToString());     }     catch (Exception ex)     {         log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod

    2.4K90发布于 2018-01-23
  • 来自专栏大内老A

    动态方法拦截(AOP)的N种解决方案

    Debug.Assert(new Foobar().Invoke() == 1); Debug.Assert(Indicator.Injected == true); } static MethodBase MonoMod.Common包中),并在方法体的前面添加了两个IL指令将Indicator的Injected属性设置为True,该方法最终返回通过这个DynamicMethodDefinition对象生成的MethodBase 和第一种方案一样,我们的代理对象依旧是封装目标对象,在实现的Invoke方案中,我们利用作为参数的IMessage 方法得到代表目标方法的MethodBase对象,进而利用它实现针对目标方法的调用。 methodCall.Args.CopyTo(copiedArgs, 0); try { object returnValue = methodCall.MethodBase.Invoke

    98310发布于 2021-01-13
  • 来自专栏单片机/c#技术分享

    frameWork

    =null) { var methodInfo = methodMsg.MethodBase as MethodInfo; = null) { Interceptor.BeforeEvent(methodMsg.MethodBase, methodMsg.InArgs ); } var result= methodMsg.MethodBase.Invoke(Instance, methodMsg.InArgs = null) { Interceptor.AfterEvent(methodMsg.MethodBase, result = null) { Interceptor.ExceptionEvent(ex, methodMsg.MethodBase);

    91320编辑于 2022-11-07
  • 来自专栏明丰随笔

    浅谈.Net反射 11

    Attributes public abstract Type BaseType public virtual bool ContainsGenericParameters public virtual MethodBase virtual object GetValue(object obj, object[] index) public void SetValue(object obj, object value) 分析MethodBase bool IsPublic public bool IsSpecialName public bool IsStatic public bool IsVirtual 方法: public static MethodBase

    53120发布于 2019-07-30
  • 来自专栏.Net、.Net Core 、Docker

    并行编程和任务(二)

    void TaskOne() { Console.WriteLine($"任务{Task.CurrentId},方法名:{System.Reflection.MethodBase.GetCurrentMethod Task.Delay(1000).Wait(); Console.WriteLine($"任务{Task.CurrentId},方法名:{System.Reflection.MethodBase.GetCurrentMethod task.Id}以及结束了"); Console.WriteLine($"现在开始的 任务是任务{Task.CurrentId},方法名称:{System.Reflection.MethodBase.GetCurrentMethod task.Id}以及结束了"); Console.WriteLine($"现在开始的 任务是任务{Task.CurrentId}.方法名称:{System.Reflection.MethodBase.GetCurrentMethod

    1.1K10发布于 2019-11-10
  • 来自专栏DotNet NB && CloudNative

    C#动态方法拦截(AOP)的5种解决方案!

    Debug.Assert(new Foobar().Invoke() == 1); Debug.Assert(Indicator.Injected == true); } static MethodBase MonoMod.Common包中),并在方法体的前面添加了两个IL指令将Indicator的Injected属性设置为True,该方法最终返回通过这个DynamicMethodDefinition对象生成的MethodBase 和第一种方案一样,我们的代理对象依旧是封装目标对象,在实现的Invoke方案中,我们利用作为参数的IMessage 方法得到代表目标方法的MethodBase对象,进而利用它实现针对目标方法的调用。 methodCall.Args.CopyTo(copiedArgs, 0); try { object returnValue = methodCall.MethodBase.Invoke

    1.6K20编辑于 2023-09-19
领券