public void SetInterceptor(InterceptorAction action) { var interceptors = Interceptors; foreach (var interceptorLocation in action.InterceptorLocations) { if (!interceptors.ContainsKey(interceptorLocation)) { interceptors.Add(interceptorLocation, new List <InterceptorAction>()); } var existingInterceptor = interceptors[interceptorLocation].FirstOrDefault(x => x.InterceptorName == action.InterceptorName); //if an interceptor with the same name exists, replace it if (existingInterceptor != null) { interceptors[interceptorLocation].Remove(existingInterceptor); } //add this interceptor to the list interceptors[interceptorLocation].Add(action); } }
/// <summary> /// 构造方法 /// </summary> /// <param name="action">拦截动作,目前只有<see cref="InterceptorAction.Demand"/></param> public InterceptorAttribute(InterceptorAction action) : this((SecurityAction)action) { }
public SecurityAuthorizeAttribute(InterceptorAction action = InterceptorAction.Demand) : base(action) { this.Enabled = true; }