public object Convert(ArgumentConveresionContext context) { if (context.ParameterInfo.ParameterType == typeof(string)) { return(context.Value?.ToString()?.ToUpper()); } return(context.Value); }
public Task InvokeAsync(InvocationContext invocationContext) { var parameters = invocationContext.TargetMethod.GetParameters(); for (int index = 0; index < invocationContext.Arguments.Length; index++) { var parameter = parameters[index]; var converterProviders = parameter.GetCustomAttributes(false).OfType <IArgumentConvertorProvider>().ToArray(); if (converterProviders.Length > 0) { var convertors = converterProviders.Select(it => it.GetArgumentConvertor()).ToArray(); var value = invocationContext.Arguments[0]; foreach (var convertor in convertors) { var context = new ArgumentConveresionContext(parameter, value); value = convertor.Convert(context); } invocationContext.Arguments[index] = value; } } return(_next(invocationContext)); }