1 namespace System.Web.Mvc {
2     using System.Collections.Generic;
3     using System.Linq;
4 
5     public class FilterInfo {
6         private List<IActionFilter> _actionFilters = new List<IActionFilter>();
7         private List<IAuthorizationFilter> _authorizationFilters = new List<IAuthorizationFilter>();
8         private List<IExceptionFilter> _exceptionFilters = new List<IExceptionFilter>();
9         private List<IResultFilter> _resultFilters = new List<IResultFilter>();
10 
FilterInfo()11         public FilterInfo() {
12         }
13 
FilterInfo(IEnumerable<Filter> filters)14         public FilterInfo(IEnumerable<Filter> filters) {
15             // evaluate the 'filters' enumerable only once since the operation can be quite expensive
16             var filterInstances = filters.Select(f => f.Instance).ToList();
17 
18             _actionFilters.AddRange(filterInstances.OfType<IActionFilter>());
19             _authorizationFilters.AddRange(filterInstances.OfType<IAuthorizationFilter>());
20             _exceptionFilters.AddRange(filterInstances.OfType<IExceptionFilter>());
21             _resultFilters.AddRange(filterInstances.OfType<IResultFilter>());
22         }
23 
24         public IList<IActionFilter> ActionFilters {
25             get {
26                 return _actionFilters;
27             }
28         }
29 
30         public IList<IAuthorizationFilter> AuthorizationFilters {
31             get {
32                 return _authorizationFilters;
33             }
34         }
35 
36         public IList<IExceptionFilter> ExceptionFilters {
37             get {
38                 return _exceptionFilters;
39             }
40         }
41 
42         public IList<IResultFilter> ResultFilters {
43             get {
44                 return _resultFilters;
45             }
46         }
47     }
48 }
49