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

    ARouter源码解析(二)前言拦截器解析

    extends IInterceptor>> entry : Warehouse.interceptorsIndex.entrySet()) { Class IInterceptor iInterceptor = interceptorClass.getConstructor().newInstance(); iInterceptor.init(context); Warehouse.interceptors.add(iInterceptor); 在 init 方法中,做的主要事情就是遍历所有 IInterceptor class 并创建出对象,调用其 init 方法,完成初始化操作。 iInterceptor = Warehouse.interceptors.get(index); iInterceptor.process(postcard, new InterceptorCallback

    78730发布于 2019-01-03
  • 来自专栏俞其荣的博客

    ARouter源码解析(二)

    extends IInterceptor>> entry : Warehouse.interceptorsIndex.entrySet()) { Class IInterceptor iInterceptor = interceptorClass.getConstructor().newInstance(); iInterceptor.init(context); Warehouse.interceptors.add(iInterceptor); 在 init 方法中,做的主要事情就是遍历所有 IInterceptor class 并创建出对象,调用其 init 方法,完成初始化操作。 iInterceptor = Warehouse.interceptors.get(index); iInterceptor.process(postcard, new InterceptorCallback

    44930编辑于 2022-07-28
  • 来自专栏lzj_learn_note

    阿里ARouter拦截器使用及源码解析(二)

    自定义拦截器需要实现IInterceptor接口,并且添加@Interceptor的注解,其中priority为拦截器的优先级,值越小,优先级越高;然后实现pocess()和init()方法。 拦截器1:Test1Interceptor @Interceptor(priority = 5) public class Test1Interceptor implements IInterceptor IInterceptor iInterceptor = interceptorClass.getConstructor().newInstance(); iInterceptor.init(context); Warehouse.interceptors.add(iInterceptor); iInterceptor = Warehouse.interceptors.get(index); iInterceptor.process(postcard, new InterceptorCallback

    3K30发布于 2018-09-12
  • 来自专栏DotNet NB && CloudNative

    .NET Core 利用委托实现动态流程组装

    接下来进入正题 1、定义接口IInterceptor 定义好我们AOP需要实现的接口,不同职责可以定义不同接口,大家根据实际情况划分 internal interface IInterceptor { } internal interface IInterceptorAction : IInterceptor { ///

    /// 执行之前 /// </summary 且利于后面反射查找 [AttributeUsage(AttributeTargets.Class)] internal class BaseInterceptAttribute : Attribute, IInterceptor 方法执行后执行的事件</param> /// <returns></returns> public T Create(T decorated, IEnumerable<IInterceptor

    53910编辑于 2022-03-22
  • 来自专栏鸿蒙开发笔记

    HarmonyOS 开发实践——ZRouter让系统路由表变的更简单(轻量级动态路由库)

    : ((fromContext: NavDestinationContext) => void) | undefined = (fromContext) => { console.log("IInterceptor 添加多个拦截器单个拦截器的使用方式和全局拦截器是类似的,首先实现接口IInterceptor,然后使用setInterceptor()方法注册拦截器,,代码示例如下:export interface IInterceptor process: ", 100, context.name) return context } } as IInterceptor) // 第二种方式设置拦截器,类的实例对象的形式 ZRouter.setInterceptor(new UrlInterceptor())}export class UrlInterceptor implements IInterceptor { id=69&name=harAPage3")})拦截器:export class UrlInterceptor implements IInterceptor { // 设置拦截器优先级,数值越大则优先执行

    57220编辑于 2024-10-28
  • 来自专栏单片机/c#技术分享

    frameWork

    public class DynamicProxy<T> : RealProxy { public T Instance = default; public IInterceptor T)) { } public T GetInstance< Target, TInterceptor>() where TInterceptor: IInterceptor DispatchProxy { ///

    /// 执行方法接口 /// private IInterceptor return proxy; } /// /// 创建代理,targetType为类,interceptorType继承IInterceptor return proxy; } /// /// tIService为接口,tService实现tIService接口,intercer继承IInterceptor

    90720编辑于 2022-11-07
  • 来自专栏.Net Core技术分享

    .NET Core依赖注入集成Dynamic Proxy

    = (provider) => { var target = provider.GetService(implType); List<IInterceptor > interceptors = interceptorTypes.ToList().ConvertAll<IInterceptor>(interceptorType => { return provider.GetService(interceptorType) as IInterceptor; });

    1.3K20发布于 2019-09-23
  • 来自专栏学无止境

    【C#】使用 Castle 实现 AOP,以及 Autofac 集成 Castle

    public void Add(string name) => Console.WriteLine($"新增产品:{name}"); } public class LoggerInterceptor : IInterceptor static void Main(string[] args) { ProxyGenerator generator = new ProxyGenerator(); IInterceptor }"); } static void Main(string[] args) { ProxyGenerator generator = new ProxyGenerator(); IInterceptor Console.WriteLine($"异步新增产品:{name}"); }); } } public class LoggerInterceptor : IInterceptor public class LoggerInterceptor : IInterceptor { readonly LoggerAsyncInterceptor interceptor;

    1.8K30发布于 2021-02-25
  • 来自专栏游戏杂谈

    fabrication的拦截器Interceptors简介

    interceptor The interceptor object to register. 9: */ 10: public function addInterceptor(interceptor:IInterceptor interceptor The interceptor object to remove. 19: */ 20: public function removeInterceptor(interceptor:IInterceptor 31: public function run():void { 32: var n:int = interceptors.length; 33: var interceptor:IInterceptor

    54620发布于 2018-11-16
  • 来自专栏个人路线

    ZRouter 动态路由框架

    : ((fromContext: NavDestinationContext) => void) | undefined = (fromContext) => { console.log("IInterceptor InterceptorInfo) => void) | undefined = (info)=>{ if (info.notRegistered) return console.log("IInterceptor 自定义拦截器 自定义拦截器,首先实现接口 IInterceptor,然后使用 setInterceptor()方法注册拦截器,,代码示例如下: export interface IInterceptor (): void { ZRouter.setInterceptor(new UrlInterceptor()) } export class UrlInterceptor implements IInterceptor id=69&name=harAPage3") }) 拦截器: export class UrlInterceptor implements IInterceptor { // 设置拦截器优先级,数值越大则优先执行

    50510编辑于 2025-01-10
  • 来自专栏办公魔盒

    VB.NET 实现类似JAVA的AOP切面编程,实现菜单权限控制

    Castle.Core的拦截接口 '''

    ''' 菜单拦截器 ''' Public Class BarMenuInterceptor Implements IInterceptor Private Sub IInterceptor_Intercept(invocation As IInvocation) Implements IInterceptor.Intercept

    70520编辑于 2023-03-02
  • 来自专栏数据结构和算法

    ASP.NET Core 使用记录2

    创建 UserServiceInterceptor 拦截类,继承自 IInterceptor: public class UserServiceInterceptor:IInterceptor {

    58110编辑于 2023-11-30
  • 来自专栏NetCore 从壹开始

    从壹开始前后端分离【 .NET Core2.0 +Vue2.0 】框架之十 || AOP面向切面编程浅解析: 服务切面缓存

    AOP拦截器 在Blog.Core新建文件夹AOP,并添加拦截器BlogLogAOP,并设计其中用到的日志记录Logger方法或者类 关键的一些知识点,注释中已经说明了,主要是有以下: 1、继承接口IInterceptor 2、实例化接口IINterceptor的唯一方法Intercept 3、void Proceed();表示执行当前的方法和object ReturnValue { get; set; }执行后调用,object ///

    /// 拦截器BlogLogAOP 继承IInterceptor接口 /// public class BlogLogAOP : IInterceptor { /// /// 实例化IInterceptor唯一方法 /// ,并实现Intercept   /// /// 面向切面的缓存使用 /// public class BlogCacheAOP : IInterceptor

    60920编辑于 2022-04-10
  • 来自专栏晓晨的专栏

    .NET 通过 Autofac 和 DynamicProxy 实现AOP

    第一步:创建拦截器   下面是一个简单的拦截器示例,该拦截器的功能是显示被拦截的方法名称、参数列表和返回结果 1 ///

    2 /// 拦截器 需要实现 IInterceptor 接口 Intercept方法 3 /// 4 public class CallLogger: IInterceptor 5 { 6 / 命名注入 2 builder.Register(c => new CallLogger(Console.Out)) 3 .Named<IInterceptor

    2.2K30发布于 2018-06-22
  • 来自专栏振兴的Android修炼手册

    Android项目解耦--路由框架ARouter源码解析

    extends IInterceptor>> interceptorsIndex = new UniqueKeyTreeMap<>("More than one interceptors use same extends IInterceptor>> entry : Warehouse.interceptorsIndex.entrySet()) { Class //反射机制构造自定义的每一个拦截器实例 IInterceptor iInterceptor = interceptorClass.getConstructor ().newInstance(); iInterceptor.init(context); iInterceptor = Warehouse.interceptors.get(index); iInterceptor.process(postcard, new InterceptorCallback

    1.2K30发布于 2020-05-29
  • 来自专栏Android进阶编程

    ARouter功能介绍以及实现原理

    如页面不存在时跳转统一错误页)动画与 Flag:支持转场动画(withTransition())和启动模式(withFlags())2、拦截器(Interceptor)自定义拦截逻辑:在跳转前执行登录验证、权限检查等操作(如 IInterceptor MutableList<RouteMeta>>() // 拦截器表:优先级 -> 拦截器类 val interceptors = sortedMapOf<Int, Class<out IInterceptor /** * 拦截器接口 */interface IInterceptor { fun process(postcard: Postcard, callback: InterceptorCallback Interceptors : IInterceptorGroup { override fun loadInto(interceptors: MutableMap<Int, Class<out IInterceptor val interceptorGroup = ARouter$$Interceptors() val interceptors = mutableMapOf<Int, Class<out IInterceptor

    37510编辑于 2025-07-09
  • 来自专栏NetCore 从壹开始

    【 .NET Core 3.0 】框架之十 || AOP 切面思想

    3、添加AOP拦截器 在api层新建文件夹AOP,添加拦截器BlogLogAOP,并设计其中用到的日志记录Logger方法或者类 关键的一些知识点,注释中已经说明了,主要是有以下: 1、继承接口IInterceptor 2、实例化接口IINterceptor的唯一方法Intercept 3、void Proceed();表示执行当前的方法 4、执行后,输出到日志文件。 namespace blog.core.test3._0.AOP { ///

    /// 拦截器BlogLogAOP 继承IInterceptor接口 /// < /summary> public class BlogLogAOP : IInterceptor { /// /// 实例化IInterceptor public BlogCacheAOP(ICaching cache) { _cache = cache; } //Intercept方法是拦截的关键所在,也是IInterceptor

    1.6K30编辑于 2022-04-10
  • 来自专栏.Net Core技术分享

    Castle DynamicProxy基本用法(AOP)

    首先,引用Castle.Core 然后,定义拦截器,实现IInterceptor接口 public class LoggerInterceptor : IInterceptor { private IProductRepository target = new ProductRepository(); ProxyGenerator generator = new ProxyGenerator(); IInterceptor 由于IAsyncInterceptor接口和DP框架中的IInterceptor接口没有关联,所以我们还需要一个同步拦截器,此处直接修改旧的同步拦截器: public class LoggerInterceptor : IInterceptor { private readonly LoggerAsyncInterceptor interceptor; public LoggerInterceptor } } 从代码中可以看到,异步拦截器LoggerAsyncInterceptor具有名为ToInterceptor()的扩展方法,该方法可以将IAsyncInterceptor接口的对象转换为IInterceptor

    2.1K20发布于 2019-09-24
  • 来自专栏技术博客文章

    深入探究 ARouter

    Interceptors 是注册了声明 Interceptor 注解, 并实现 IInterceptor 接口的类, Providers 是注册了声明 Route 注解, 并实现了 IProvider postcard) { // 递归退出条件 if (index < Warehouse.interceptors.size()) { // 获取要执行的拦截器 IInterceptor iInterceptor = Warehouse.interceptors.get(index); // 执行拦截 iInterceptor.process(postcard postcard) { // 递归退出条件 if (index < Warehouse.interceptors.size()) { // 获取要执行的拦截器 IInterceptor iInterceptor = Warehouse.interceptors.get(index); // 执行拦截 iInterceptor.process(postcard

    1K00编辑于 2022-01-15
  • 来自专栏胡飞洋的Android进阶

    “终于懂了” 系列:组件化框架 ARouter 完全解析(一) 原理详解

    iInterceptor = Warehouse.interceptors.get(index); iInterceptor.process(postcard, new InterceptorCallback IInterceptor iInterceptor = interceptorClass.getConstructor().newInstance(); static List<IInterceptor> interceptors = new ArrayList<>(); ... } Warehouse存了哪些信息呢? extends IInterceptor>>,也就是WareHouse.interceptorsIndex的类型。 loadInfo方法体内,是用接收的map来put当前module所有拦截器的class,即使用 @Interceptor 注解并实现 IInterceptor 接口的类。

    4K40编辑于 2022-11-08
领券