예제 #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>();
         }
     });
 }
        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);
        }
        /// <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);
        }
        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));
 }