src/fursvp.api/Filters/PrivateContentFilter.cs
/// <summary>
/// Filters out any unauthorized content within the collection of elements.
/// </summary>
/// <typeparam name="T">The type of content to be searched.</typeparam>
/// <param name="objects">The content collection being searched.</param>
/// <param name="readAuthorizeObject">Executes read authorization methods against this type of object.</param>
/// <param name="contextResult">The context result object that contains the content collection value to be filtered.</param>
Filters out any unauthorized content within the collection of elements.
Filters out any unauthorized content within the collection of elements .
public static void FilterMany<T>(IEnumerable<T> objects, IReadAuthorize<T> readAuthorizeObject, ObjectResult contextResult)
        {
            if (contextResult == null)
            {
                throw new ArgumentNullException(nameof(contextResult));
            }
            if (readAuthorizeObject == null)
            {
                throw new ArgumentNullException(nameof(readAuthorizeObject));
            }
            var filteredObjects = objects.Where(readAuthorizeObject.CanRead).ToList();
            foreach (var @object in filteredObjects)
            {
                readAuthorizeObject.FilterUnauthorizedContent(@object);
            }
            contextResult.Value = filteredObjects;
        }
public static void FilterMany < T > ( IEnumerable < T > objects , IReadAuthorize < T > readAuthorizeObject , ObjectResult contextResult ) { if ( contextResult == null ) { throw new ArgumentNullException ( nameof ( contextResult ) ) ; } if ( readAuthorizeObject == null ) { throw new ArgumentNullException ( nameof ( readAuthorizeObject ) ) ; } var filteredObjects = objects . Where ( readAuthorizeObject . CanRead ) . ToList ( ) ; foreach ( var @object in filteredObjects ) { readAuthorizeObject . FilterUnauthorizedContent ( @object ) ; } contextResult . Value = filteredObjects ; }
Filters out any unauthorized content within the collection of elements.
Filters out any unauthorized content within the collection of elements .
objects
IEnumerable<T>
The content collection being searched.
The content collection being searched .
readAuthorizeObject
IReadAuthorize<T>
Executes read authorization methods against this type of object.
Executes read authorization methods against this type of object .
contextResult
ObjectResult
The context result object that contains the content collection value to be filtered.
The context result object that contains the content collection value to be filtered .
typeparam
The type of content to be searched.
The type of content to be searched .