public List <ServiceDescription> Parse(List <Type> typesInAssembly, XDocument m_assemblyDocumentation = null) { var serviceDescriptions = new List <ServiceDescription>(); foreach (var type in typesInAssembly) { if (m_documentTypeQuestions.Any(question => question.ShouldDocumentType(type)) == false) { continue; } var xPathQueryForType = Helper.GetXPathQueryForType(type.FullName); var documentationForService = m_assemblyDocumentation?.XPathSelectElement(xPathQueryForType); var serviceDescription = new ServiceDescription { Name = type.Name, Desription = documentationForService?.Value }; serviceDescriptions.Add(serviceDescription); foreach (var method in type.GetMethods()) { if (m_documentMethodQuestions.Any(question => question.ShouldDocumentMethod(method)) == false) { continue; } IFormatorRequest formatorRequest = new MethodFormatorRequest() { MethodInfo = method }; IFormator formator = m_formatorFactory.CreateFormator(formatorRequest); var xPathQueryForMethod = Helper.GetXPathQueryForMethod(type.FullName, method.Name); var documentationForMethod = m_assemblyDocumentation?.XPathSelectElement(xPathQueryForMethod); serviceDescription.ServiceMethods.Add(new ServiceMethod { Name = method.Name, Description = documentationForMethod?.Value.Trim(' ', '\n'), Signature = formator.Format(formatorRequest), //GetMethodSignature(method) }); serviceDescription.TypesServiceDependsOn = m_methodDependencyfinder.FindDependencies(method, typesInAssembly).ToList(); } } return(serviceDescriptions); }
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)); }