当前位置: 首页 > news >正文

MethodInterceptor

目录

1 MethodInterceptor

1.1 HandleSync

1.2 HandleException

1.3 /// This will be called via Reflection

  1. MethodInterceptor
    1. HandleSync

        private void HandleSync(IReadOnlyList<MethodFilterAttribute> filterAttributes, IReadOnlyList<ExceptionFilterAttribute> exceptionFilterAttributes, MethodExecutingContext methodExecutingContext)

        {

            foreach (var f in filterAttributes)

            {

                try

                {

                    if (methodExecutingContext.Result == null) f.OnMethodExecuting(methodExecutingContext);

                }

                catch (Exception ex)

                {

                var exContext = new MethodExceptionContext(ex, methodExecutingContext);

HandleException(exceptionFilterAttributes, exContext);

                if (!exContext.Handled)

                {

throw;

                }

                }

            }

            var reversedFilterAttributes = filterAttributes.Reverse();

            var methodExecutedContext = new MethodExecutedContext(methodExecutingContext);

            foreach (var f in reversedFilterAttributes)

            {

                try

                {

                    f.OnMethodExecuted(methodExecutedContext);

                }

                catch (Exception ex)

                {

                var exContext = new MethodExceptionContext(ex, methodExecutedContext);

                HandleException(exceptionFilterAttributes, exContext);

                if (!exContext.Handled)

                {

                throw;

                }

                }

            }

        }

    1.         HandleException

        private void HandleException(IReadOnlyList<ExceptionFilterAttribute> exceptionFilterAttributes, MethodExceptionContext exceptionContext)

        {

            foreach (var f in exceptionFilterAttributes)

            {

                try

                {

                    if (!exceptionContext.Handled)

                    {

                        f.OnException(exceptionContext);

                    }

                }

                catch (Exception ex)

                {

                    throw new AggregateException(ex.Message, ex, exceptionContext.Exception);

                }

            }

        }

    /// <summary>

http://www.lryc.cn/news/102253.html

相关文章:

  • PID模块化__以stm32直流电机速度为例
  • Java ~ Collection/Executor ~ DelayQueue【总结】
  • 前端高级面试题-安全相关
  • 【前缀和】560.和为 K 的子数组
  • 【Docker】安全及日志管理
  • 基于x-scan扫描线的3D模型渲染算法
  • LeetCode36.Valid-Sudoku<有效的数独>
  • Linux中的pause函数
  • CommonCollections6链分析
  • 优化基于tcp,socket的ftp文件传输程序
  • MySQL 数据库 【增删查改(二)】
  • 力扣 -- 978. 最长湍流子数组
  • 甘特图 Dhtmlx Gantt
  • iOS 应用上架流程详解
  • Python入门【LEGB规则、面向对象简介、面向过程和面向对象思想、面向对象是什么? 对象的进化 、类的定义、对象完整内存结构 】(十三)
  • 【消息中间件】原生PHP对接Uni H5、APP、微信小程序实时通讯消息服务
  • 【C语言初阶】指针篇—上
  • 基于FasterRCNN深度学习网络的车辆检测算法matlab仿真
  • 机器学习深度学习——多层感知机
  • Django模型将模型注释同步到数据库
  • STM32 Flash学习(二)
  • kotlin获取泛型集合的类型信息
  • AQS源码解析
  • 关于在VS2017中编译Qt项目遇到的问题
  • Python web实战 | 使用 Flask 实现 Web Socket 聊天室
  • Android10 Recovery系列(一)隐藏recovery菜单项
  • 选好NAS网络储存解决方案,是安全储存的关键
  • AnimateDiff论文解读-基于Stable Diffusion文生图模型生成动画
  • centos7安装tomcat
  • 【C#教程】零基础从入门到精通