zoukankan      html  css  js  c++  java
  • C# castle 拦截器

    拦接器

    public class AutoDesensitizationMethodInterceptor : IMethodInterceptor
        {
            public object Intercept(IMethodInvocation invocation, params object[] args)
            {
                MethodInfo methodInvocationTarget = invocation.MethodInvocationTarget;
                object obj = invocation.Proceed(args);
                return AttributeVerification.VerificationDesensitization<Object>(obj);
            }
        }
    View Code

    拦接器

    public class AutoDesensitizationInspector : IContributeComponentModelConstruction
        {
            /// <summary>
            ///
            /// </summary>
            /// <param name="kernel"></param>
            /// <param name="model"></param>
            // Token: 0x0600048E RID: 1166 RVA: 0x00010344 File Offset: 0x0000E544
            public void ProcessModel(IKernel kernel, ComponentModel model)
            {
                //ICacheFactory autoCacheManager = kernel[typeof(IAutoCacheManager)] as IAutoCacheManager;
                foreach (MethodInfo m in model.Implementation.GetMethods()){
                    if (m.IsDefined(typeof(DesensitizationMethodAttribute), true))
                    {
                        model.Interceptors.Add(new InterceptorReference(typeof(AutoDesensitizationMethodInterceptor)));
                    }
                }
            }
    View Code
    public class AutoDesensitizationFacility : AbstractFacility
        {
    
            protected override void Init()
            {
                base.Kernel.ComponentModelBuilder.AddContributor(new AutoDesensitizationInspector());
                base.Kernel.AddComponent("AutoDesensitization", typeof(AutoDesensitizationMethodInterceptor));
            }
        }
    View Code

    配置web.config

    <castle>
        <facilities>
          <facility id="AutoDesensitization" type="命名空间.AutoDesensitizationFacility, 程序集" />
        </facilities>
    </castle>
  • 相关阅读:
    JS函数调用的方法
    JS 正则表达式
    JS replace()方法-字符串首字母大写
    JS案例之3——倒计时
    JS案例之2——cycle元素轮播
    jsp自定义标签
    每日记载内容总结23
    maven项目部分知识
    eclipse中整合springMvc,velocity和sitemesh
    eclipse中整合springMvc和velocity
  • 原文地址:https://www.cnblogs.com/xiaoruilin/p/14791255.html
Copyright © 2011-2022 走看看