/// <summary> /// Returns the methods for the given <paramref name="type"/>. /// </summary> /// <param name="type">The type for which to return the methods.</param> public IEnumerable <MethodDocumentation> GetMethods(TypeDocumentation type) { if (null == type) { throw new ArgumentNullException(nameof(type)); } var nodes = this.Document.DocumentElement.SelectNodes($"members/member[starts-with(@name, 'M:{type.Member.FullName}.')]"); foreach (XmlNode node in nodes) { MethodBase method = null; var cref = new CRef(node.Attributes["name"].Value); if (cref.IsMethod) { method = cref.ToMethod(); } if (null != method) { yield return(new MethodDocumentation(node, method)); } } yield break; }
/// <summary> /// Returns the property that <paramref name="propertyString"/> represents. /// </summary> public static PropertyInfo ToProperty(this string propertyString) { PropertyInfo pi = null; List <Type> paramTypes = new List <Type>(); if (propertyString.Contains('(')) { var paramTypesString = propertyString.Substring(propertyString.IndexOf('(') + 1, propertyString.IndexOf(')') - propertyString.IndexOf('(') - 1); propertyString = propertyString.Substring(0, propertyString.IndexOf('(')); var arr = paramTypesString.SplitTypeDefinitions(); foreach (var item in arr) { var t = item.ToType(); if (null != t) { paramTypes.Add(t); } } } var propertyName = propertyString.Substring(propertyString.LastIndexOf('.') + 1); var typeRef = new CRef($"T:{propertyString.Substring(0, propertyString.LastIndexOf('.'))}"); var declaringType = typeRef.ToType(); pi = declaringType.FindProperty(propertyName, paramTypes); return(pi); }