private static IEnumerable<ParameterInfo> ExtractProgressParameter(ParameterInfo[] parameters, out Type progressReportingType)
{
var lastParameter = parameters.LastOrDefault();
progressReportingType = null;
if (IsProgressType(lastParameter))
{
// This method takes an IProgress<T> as the last parameter and thus supports progress reporting
progressReportingType = lastParameter.ParameterType.GenericTypeArguments[0];
// Strip the IProgress<T> param from the method descriptor params list
// as we don't want to include it when trying to match methods
return parameters.Take(parameters.Length - 1);
}
return parameters;
}