/// <summary> /// Methods are sorted: /// <list type='number'> /// <item>alphabetically by namespace</item> /// <item>then into <see cref='OperatorOrder'/></item> /// <item>then as a normal method (see <see cref='DotNetQualifiedMethodName.CompareTo(object)'/></item> /// </list> /// </summary> public int CompareTo(object b) { if (!(b is DotNetMethodOperator)) { return(-1); } DotNetMethodOperator other = (b as DotNetMethodOperator); if (this.Name.FullNamespace != other.Name.FullNamespace) { return(this.Name.FullNamespace.CompareTo(other.Name.FullNamespace)); } if (this.Name.LocalName != other.Name.LocalName) { int indexThis = Array.IndexOf(OperatorOrder, this.Name.LocalName); int indexOther = Array.IndexOf(OperatorOrder, other.Name.LocalName); if (indexThis == -1 && indexOther == -1) { return(this.Name.LocalName.CompareTo(other.Name.LocalName)); } return(indexThis.CompareTo(indexOther)); } return(this.MethodName.CompareTo(other.MethodName)); }
/// <summary> /// Parse .Net XML documentation for method signature data. /// </summary> /// <param name="memberElement">Expects tag "member".</param> /// <example><![CDATA[<member name="M:Namespace.Type.MethodName(System.Int32,System.String)"></member>]]></example> public static DotNetMethod FromVisualStudioXml(XElement memberElement) { string signature = memberElement.GetAttributeValue("name"); if (signature == null) { return(new DotNetMethod()); } DotNetQualifiedMethodName methodName = DotNetQualifiedMethodName.FromVisualStudioXml(signature); //for constructors bool isConstructor = (methodName.LocalName.EndsWith("#ctor") || methodName.LocalName.EndsWith("#cctor")); bool isStatic = methodName.LocalName.EndsWith("#cctor"); //for destructors bool isDestructor = (methodName.LocalName == "Finalize" && methodName.Parameters.Count == 0); //for operators bool isOperator = methodName.LocalName.StartsWith("op_"); DotNetMethod method = null; if (isConstructor) { method = new DotNetMethodConstructor(methodName, isStatic); } else if (isDestructor) { method = new DotNetMethodDestructor(methodName); } else if (isOperator) { method = new DotNetMethodOperator(methodName); } else { method = new DotNetMethod(methodName); } method.ParseVisualStudioXmlDocumentation(memberElement); return(method); }