コード例 #1
0
 private static bool ShouldIntercept(Type type)
 {
     // 拦截器的要求
     // 1、继承自IBasicRepository的仓储
     // 2、继承自INeedRule接口的实体
     return(!DynamicProxyIgnoreTypes.Contains(type) &&
            type.IsAssignableTo(typeof(IBasicRepository <>)) &&
            type.GetGenericTypeDefinition().IsAssignableTo(typeof(INeedRule)));
 }
コード例 #2
0
 public override void PreConfigureServices(ServiceConfigurationContext context)
 {
     context.Services.OnRegistred(onServiceRegistredContext =>
     {
         if (typeof(IMyAppService).IsAssignableFrom(onServiceRegistredContext.ImplementationType) &&
             !DynamicProxyIgnoreTypes.Contains(onServiceRegistredContext.ImplementationType))
         {
             onServiceRegistredContext.Interceptors.TryAdd <ValidationInterceptor>();
         }
     });
 }
コード例 #3
0
        private static bool ShouldIntercept(Type type)
        {
            if (DynamicProxyIgnoreTypes.Contains(type))
            {
                return(false);
            }

            if (type.GetMethods().Any(m => m.IsDefined(typeof(LocalCacheAttribute), true)))
            {
                return(true);
            }

            return(false);
        }
コード例 #4
0
        /// <summary>
        /// Shoulds the intercept.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        private static bool ShouldIntercept(Type type)
        {
            if (DynamicProxyIgnoreTypes.Contains(type))
            {
                return(false);
            }
            // 首先判断类型上面是否使用了辅助类型。
            if (ShouldAuditTypeByDefault(type))
            {
                return(true);
            }
            //如果任意方法上面标注了 AuditedAttribute 特性,则仍然为该类型注入拦截器。
            if (type.GetMethods().Any(m => m.IsDefined(typeof(AuditedAttribute), true)))
            {
                return(true);
            }

            return(false);
        }
コード例 #5
0
        private static bool ShouldIntercept(Type type)
        {
            if (DynamicProxyIgnoreTypes.Contains(type))
            {
                return(false);
            }

            if (ShouldAuditTypeByDefaultOrNull(type) == true)
            {
                return(true);
            }

            if (type.GetMethods().Any(m => m.IsDefined(typeof(AuditedAttribute), true)))
            {
                return(true);
            }

            return(false);
        }
コード例 #6
0
 private static bool ShouldIntercept(Type type)
 {
     return(!DynamicProxyIgnoreTypes.Contains(type) &&
            (type.IsDefined(typeof(RequiresLimitFeatureAttribute), true) ||
             AnyMethodHasRequiresLimitFeatureAttribute(type)));
 }
コード例 #7
0
 private static bool ShouldIntercept(Type type)
 {
     return(!DynamicProxyIgnoreTypes.Contains(type) && typeof(IValidationEnabled).IsAssignableFrom(type));
 }
コード例 #8
0
 private static bool ShouldIntercept(Type type)
 {
     return(!DynamicProxyIgnoreTypes.Contains(type) && UnitOfWorkHelper.IsUnitOfWorkType(type.GetTypeInfo()));
 }
コード例 #9
0
 private static bool ShouldIntercept(Type type)
 {
     return(!DynamicProxyIgnoreTypes.Contains(type) && typeof(IGlobalFeatureCheckingEnabled).IsAssignableFrom(type));
 }