public static XmlElement GetXmlFromMember(MemberInfo member, bool throwError = true) { ExceptionHelper.ThrowIfNull("member", member); // First character [0] of member type is prefix character in the name in the XML char prefix = member.MemberType.ToString()[0]; ParameterInfo[] parameters = null; if (((PropertyInfo)member).CanRead) { parameters = ((PropertyInfo)member).GetGetMethod().GetParameters(); } List <string> strParameters = new List <string>(); //Handles getter/setter style properties if (parameters != null && parameters.Length > 0) { foreach (ParameterInfo parameterInfo in parameters) { strParameters.Add(DocsTypeService.GetTypeFullNameForXmlDoc(parameterInfo.ParameterType, parameterInfo.IsOut | parameterInfo.ParameterType.IsByRef, true)); } return(DocsTypeService.GetXmlFromName(member.ReflectedType, prefix, member.Name + "({0})".With(string.Join(",", strParameters)), throwError)); } //handles regular properties else { return(DocsTypeService.GetXmlFromName(member.DeclaringType, member.MemberType.ToString()[0], member.Name, throwError)); } }
public static XmlElement GetXmlFromMember(MethodBase method, bool throwError = true) { if (method == null) { throw new ArgumentNullException(nameof(method)); } // Calculate the parameter string as this is in the member name in the XML var parameters = new List <string>(); foreach (var parameterInfo in method.GetParameters()) { parameters.Add(DocsTypeService.GetTypeFullNameForXmlDoc(parameterInfo.ParameterType, parameterInfo.IsOut | parameterInfo.ParameterType.IsByRef, true)); } //AL: 15.04.2008 ==> BUG-FIX remove “()” if parametersString is empty if (parameters.Count > 0) { //JA: 11.8.2016 Add ``1 to end of the resulting name if the method is a generic method var result = DocsTypeService.GetXmlFromName(method.DeclaringType, 'M', string.Format("{0}{1}{2}", method.Name, method.IsGenericMethod ? "``1" : string.Empty, string.Format("({0})", string.Join(",", parameters))), false); // Try a fallback for case where a method with generic parameters is defined on base class. if (result == null) { var typedParameters = new List <string>(); for (var i = 1; i <= parameters.Count; i++) { typedParameters.Add(string.Format("`{0}", i)); } return(DocsTypeService.GetXmlFromName(method.DeclaringType, 'M', string.Format(method.Name + "({0})", string.Join(",", typedParameters)), throwError)); } if (result == null && throwError) { ThrowHelper.ThrowDocNotFound(); } return(result); } else { return(DocsTypeService.GetXmlFromName(method.DeclaringType, 'M', method.Name, throwError)); } }
public static XmlElement GetXmlFromMember(MethodBase method, bool throwError = true) { ExceptionHelper.ThrowIfNull("method", method); // Calculate the parameter string as this is in the member name in the XML var parameters = new List <string>(); foreach (var parameterInfo in method.GetParameters()) { parameters.Add(DocsTypeService.GetTypeFullNameForXmlDoc(parameterInfo.ParameterType, true)); } //AL: 15.04.2008 ==> BUG-FIX remove “()” if parametersString is empty if (parameters.Count > 0) { var result = DocsTypeService.GetXmlFromName(method.DeclaringType, 'M', method.Name + "({0})".With(String.Join(",", parameters)), false); // Try a fallback for case where a method with generic parameters is defined on base class. if (result == null) { var typedParameters = new List <string>(); for (int i = 1; i <= parameters.Count; i++) { typedParameters.Add("`{0}".With(i)); } return(DocsTypeService.GetXmlFromName(method.DeclaringType, 'M', method.Name + "({0})".With(String.Join(",", typedParameters)), throwError)); } if (result == null && throwError) { ThrowHelper.ThrowDocNotFound(); } return(result); } else { return(DocsTypeService.GetXmlFromName(method.DeclaringType, 'M', method.Name, throwError)); } }
public static XmlElement GetXmlFromMember(MemberInfo member, bool throwError = true) { if (member == null) { throw new ArgumentNullException(nameof(member)); } // First character [0] of member type is prefix character in the name in the XML. var prefix = member.MemberType.ToString()[0]; ParameterInfo[] parameters = null; var methodBase = member as MethodBase; var propertyInfo = member as PropertyInfo; if (propertyInfo != null && propertyInfo.CanRead) { methodBase = propertyInfo.GetGetMethod(); } if (methodBase != null) { parameters = methodBase.GetParameters(); } var strParameters = new List <string>(); // Handles getter/setter style properties. if (parameters != null && parameters.Length > 0) { foreach (ParameterInfo parameterInfo in parameters) { strParameters.Add(DocsTypeService.GetTypeFullNameForXmlDoc(parameterInfo.ParameterType, parameterInfo.IsOut | parameterInfo.ParameterType.IsByRef, true)); } return(DocsTypeService.GetXmlFromName(member.ReflectedType, prefix, string.Format(member.Name + "({0})", string.Join(",", strParameters)), throwError)); } //handles regular properties else { return(DocsTypeService.GetXmlFromName(member.DeclaringType, member.MemberType.ToString()[0], member.Name, throwError)); } }