/// <summary> /// Creates a new ContextFilter attribute with the specified filter type and context types. /// </summary> /// <param name="filterType">The type of filter to apply</param> /// <param name="filterPolicy">The filter policy to apply.</param> /// <param name="contextTypes">The contexts that will be affected by the filter.</param> public ContextFilterAttribute(ContextFilterType filterType, ContextFilterPolicy filterPolicy, params Type[] contextTypes) { if (contextTypes != null) { var baseType = typeof (Context); if (contextTypes.Any(t => t != baseType && !t.IsSubclassOf(baseType))) { throw new ArgumentException("Attempted to specify a non-context type in a context filter."); } } FilterType = filterType; FilterPolicy = filterPolicy; ContextTypes = contextTypes; }
/// <summary> /// Creates a new ContextFilter with the specified rules. /// </summary> /// <param name="filterType">The type of the filter.</param> /// <param name="filterPolicy">The filter policy that determines which types are affected by the filter.</param> /// <param name="contextTypes">The context types affected by the filter.</param> public ContextFilter(ContextFilterType filterType, ContextFilterPolicy filterPolicy, params Type[] contextTypes) { FilterType = filterType; FilterPolicy = filterPolicy; ContextTypes = contextTypes; }