protected virtual bool ApplyResponseFiltersSingle(IRequest req, IResponse res, object response)
{
var responseDto = response.GetResponseDto();
var attributes = responseDto != null
? FilterAttributeCache.GetResponseFilterAttributes(responseDto.GetType())
: null;
//Exec all ResponseFilter attributes with Priority < 0
var i = 0;
if (attributes != null)
{
for (; i < attributes.Length && attributes[i].Priority < 0; i++)
{
var attribute = attributes[i];
Container.AutoWire(attribute);
attribute.ResponseFilter(req, res, response);
Release(attribute);
if (res.IsClosed) return res.IsClosed;
}
}
if (response != null)
{
ExecTypedFilters(GlobalTypedResponseFilters, req, res, response);
if (res.IsClosed) return res.IsClosed;
}
//Exec global filters
foreach (var responseFilter in GlobalResponseFilters)
{
responseFilter(req, res, response);
if (res.IsClosed) return res.IsClosed;
}
//Exec remaining RequestFilter attributes with Priority >= 0
if (attributes != null)
{
for (; i < attributes.Length; i++)
{
var attribute = attributes[i];
Container.AutoWire(attribute);
attribute.ResponseFilter(req, res, response);
Release(attribute);
if (res.IsClosed) return res.IsClosed;
}
}
return res.IsClosed;
}