src/fursvp.api/Filters/PrivateContentFilter.cs
/// <summary>
/// Searches the response for content that implements IReadAuthorize, and invokes IReadAuthorize methods to hide private content.
/// </summary>
/// <param name="context">The Microsoft.AspNetCore.Mvc.Filters.ActionExecutedContext.</param>
Searches the response for content that implements IReadAuthorize, and invokes IReadAuthorize methods to hide private content.
Searches the response for content that implements IReadAuthorize and invokes IReadAuthorize methods to hide private content .
public void OnActionExecuted(ActionExecutedContext context)
        {
            if (!(context?.Result is ObjectResult objectResult))
            {
                return;
            }
            if (objectResult.Value == null)
            {
                return;
            }
            var objectType = objectResult.Value.GetType();
            if (objectType != null)
            {
                object readAuthorize = GetReadAuthorizeService(objectType);
                if (readAuthorize != null)
                {
                    var method = typeof(PrivateContentFilter).GetMethod(nameof(Filter));
                    var genericMethod = method.MakeGenericMethod(objectType);
                    genericMethod.Invoke(null, new object[] { objectResult.Value, readAuthorize, context });
                    return;
                }
            }
            objectType = IEnumerableGenericArgument(objectType);
            if (objectType != null)
            {
                object readAuthorize = GetReadAuthorizeService(objectType);
                if (readAuthorize != null)
                {
                    var method = typeof(PrivateContentFilter).GetMethod(nameof(FilterMany));
                    var genericMethod = method.MakeGenericMethod(objectType);
                    genericMethod.Invoke(null, new object[] { objectResult.Value, readAuthorize, context.Result });
                    return;
                }
            }
        }
public void OnActionExecuted ( ActionExecutedContext context ) { if ( ! ( context ? . Result is ObjectResult objectResult ) ) { return ; } if ( objectResult . Value == null ) { return ; } var objectType = objectResult . Value . GetType ( ) ; if ( objectType != null ) { object readAuthorize = GetReadAuthorizeService ( objectType ) ; if ( readAuthorize != null ) { var method = typeof ( PrivateContentFilter ) . GetMethod ( nameof ( Filter ) ) ; var genericMethod = method . MakeGenericMethod ( objectType ) ; genericMethod . Invoke ( null , new object [ ] { objectResult . Value , readAuthorize , context } ) ; return ; } } objectType = IEnumerableGenericArgument ( objectType ) ; if ( objectType != null ) { object readAuthorize = GetReadAuthorizeService ( objectType ) ; if ( readAuthorize != null ) { var method = typeof ( PrivateContentFilter ) . GetMethod ( nameof ( FilterMany ) ) ; var genericMethod = method . MakeGenericMethod ( objectType ) ; genericMethod . Invoke ( null , new object [ ] { objectResult . Value , readAuthorize , context . Result } ) ; return ; } } }
Searches the response for content that implements IReadAuthorize, and invokes IReadAuthorize methods to hide private content.
Searches the response for content that implements IReadAuthorize and invokes IReadAuthorize methods to hide private content .
// Try to filter a single Event being returned // Try to filter multiple objects being returned
context
ActionExecutedContext
None