/// <summary>
        /// Registers the filter with the associated action name (inferred or real) and
        /// allows the initialization of the filter.
        /// </summary>
        /// <param name="actionName"></param>
        /// <returns></returns>
        public virtual ControllerActionExpression <TController> ToAction(string actionName)
        {
            if (!FilterType.IsMvcFilter())
            {
                throw new ArgumentException("Specified argument is not an MVC filter!", "filterType");
            }

            if (currentRegistration != null)
            {
                // Remove the old registration
                Filters.Remove(currentRegistration);
            }

            // Create a new one for the
            Filters.Add(new ActionFilter {
                FilterType       = this.FilterType,
                ControllerType   = typeof(TController),
                Action           = actionName,
                ModelInitializer = Initializer,
                Order            = this.Order
            });

            // Clear it
            currentRegistration = null;
            return(this);
        }
        /// <summary>
        /// Registers the filter at the controller level.
        /// </summary>
        /// <returns></returns>
        public void Register()
        {
            currentRegistration = new ActionFilter {
                FilterType       = FilterType,
                ControllerType   = typeof(TController),
                ModelInitializer = Initializer,
                Order            = this.Order
            };

            Filters.Add(currentRegistration);
        }
Exemplo n.º 3
0
 public bool Equals(ActionFilter other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(Equals(other.ControllerType, ControllerType) && Equals(other.FilterType, FilterType));
 }
Exemplo n.º 4
0
 public bool Equals(ActionFilter other) {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return Equals(other.ControllerType, ControllerType) && Equals(other.FilterType, FilterType);
 }