private static bool ShouldIntercept(Type type) { // 拦截器的要求 // 1、继承自IBasicRepository的仓储 // 2、继承自INeedRule接口的实体 return(!DynamicProxyIgnoreTypes.Contains(type) && type.IsAssignableTo(typeof(IBasicRepository <>)) && type.GetGenericTypeDefinition().IsAssignableTo(typeof(INeedRule))); }
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); }
private static bool ShouldIntercept(Type type) { return(!DynamicProxyIgnoreTypes.Contains(type) && (type.IsDefined(typeof(RequiresLimitFeatureAttribute), true) || AnyMethodHasRequiresLimitFeatureAttribute(type))); }
private static bool ShouldIntercept(Type type) { return(!DynamicProxyIgnoreTypes.Contains(type) && typeof(IValidationEnabled).IsAssignableFrom(type)); }
private static bool ShouldIntercept(Type type) { return(!DynamicProxyIgnoreTypes.Contains(type) && UnitOfWorkHelper.IsUnitOfWorkType(type.GetTypeInfo())); }
private static bool ShouldIntercept(Type type) { return(!DynamicProxyIgnoreTypes.Contains(type) && typeof(IGlobalFeatureCheckingEnabled).IsAssignableFrom(type)); }