Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// 构造方法
 /// </summary>
 /// <param name="action">拦截动作,目前只有<see cref="InterceptorAction.Demand"/></param>
 public InterceptorAttribute(InterceptorAction action)
     : this((SecurityAction)action)
 {
 }
Esempio n. 3
0
 public SecurityAuthorizeAttribute(InterceptorAction action = InterceptorAction.Demand) : base(action)
 {
     this.Enabled = true;
 }
Esempio n. 4
0
 /// <summary>
 /// 构造方法
 /// </summary>
 /// <param name="action">拦截动作,目前只有<see cref="InterceptorAction.Demand"/></param>
 public InterceptorAttribute(InterceptorAction action) : this((SecurityAction)action)
 {
 }