Go to the documentation of this file.00001 using N2.Collections;
00002 using System.Security.Principal;
00003 using N2.Security;
00004
00005 namespace N2.Extensions
00006 {
00007 public static class FilterExtensions
00008 {
00013 public static T FilterByAccess<T>(this T item) where T: ContentItem
00014 {
00015 return item.FilterWith(new AccessFilter());
00016 }
00017
00023 public static T FilterByAccess<T>(this T item, IPrincipal user) where T : ContentItem
00024 {
00025 return item.FilterWith(new AccessFilter(user, AccessFilter.CurrentSecurityManager()));
00026 }
00027
00032 public static T FilterByNavigation<T>(this T item) where T : ContentItem
00033 {
00034 return item.FilterWith(new NavigationFilter());
00035 }
00036
00037 private static T FilterWith<T>(this T item, ItemFilter filter) where T: ContentItem
00038 {
00039 if (item == null)
00040 return null;
00041
00042 if (filter.Match(item))
00043 return item;
00044
00045 return null;
00046 }
00047 }
00048 }