public string Format(IFormatorRequest formatorRequest) { if ((formatorRequest is ListOfParameterFormatorRequest) == false) { throw new ArgumentException($"Parameter formator only takes a {typeof(ListOfParameterFormatorRequest).Name}"); } ListOfParameterFormatorRequest listOfParameterFormatorRequest = (ListOfParameterFormatorRequest)formatorRequest; var formatedParamaters = listOfParameterFormatorRequest.Parameters.Select(param => { IFormatorRequest parameterFormatorRequest = new ParameterFormatorRequest { Parameter = param }; IFormator formator = m_formatorFactory.CreateFormator(parameterFormatorRequest); return(formator.Format(parameterFormatorRequest)); }); return(string.Join(", ", formatedParamaters)); }
public string Format(IFormatorRequest formatorRequest) { if ((formatorRequest is MethodFormatorRequest) == false) { throw new ArgumentException($"Expected {typeof(MethodFormatorRequest)}"); } var methodFormatorRequest = (MethodFormatorRequest)formatorRequest; var returnParamName = methodFormatorRequest.MethodInfo.ReturnType.Name; IFormatorRequest paramFormatorRequest = new ListOfParameterFormatorRequest() { Parameters = methodFormatorRequest.MethodInfo.GetParameters().ToList() }; var parameterFormator = m_formatorFactory.CreateFormator(paramFormatorRequest); var formatedParamaters = parameterFormator.Format(paramFormatorRequest); //var paramaters = string.Join(", ", methodFormatorRequest.MethodInfo.GetParameters().Select(GetParamNameValue)); return(string.Format("{0} {1}({2})", returnParamName, methodFormatorRequest.MethodInfo.Name, formatedParamaters)); }