コード例 #1
0
        private static string GetLongDescription(MethodInfo method, IProxyMetadata proxyMetadata, XmlDocMetadata methodDocumentation)
        {
            if (proxyMetadata == null)
            {
                return Resources.Global.MissingDescription;
            }

            string description = proxyMetadata.GetLongDescription(method);

            if (description == null && methodDocumentation != null)
            {
                description = methodDocumentation.Remarks;
            }

            return (description ?? Resources.Global.MissingDescription).Trim();
        }
コード例 #2
0
ファイル: XmlDocParser.cs プロジェクト: dstarosta/GitProjects
        private XmlDocMetadata GetMethodMetadata(XDocument xmlDoc, MethodInfo method)
        {
            ParameterInfo[] parameters = method.GetParameters();
            string methodSignature = GetMethodSignature(method, parameters);

            if (xmlDoc.Root == null)
            {
                return null;
            }

            XElement methodDoc = xmlDoc.Root.Elements("members")
                                            .Elements("member")
                                            .FirstOrDefault(x => x.Attribute("name") != null && x.Attribute("name").Value == methodSignature);

            if (methodDoc == null)
            {
                return null;
            }

            XElement summaryDoc = methodDoc.Element("summary");
            XElement remarksDoc = methodDoc.Element("remarks");
            XElement returnsDoc = methodDoc.Element("returns");

            var metadata = new XmlDocMetadata
            {
                Method = method,
                Summary = summaryDoc != null ? summaryDoc.Value.Trim() : String.Empty,
                Remarks = remarksDoc != null ? remarksDoc.Value.Trim() : String.Empty,
                Returns = returnsDoc != null ? returnsDoc.Value.Trim() : String.Empty,
            };

            if (parameters.Length == 0)
            {
                return metadata;
            }

            foreach (ParameterInfo parameter in parameters)
            {
                XElement parameterDoc = methodDoc.Elements("param")
                                                 .FirstOrDefault(x => x.Attribute("name") != null && x.Attribute("name").Value == parameter.Name);

                if (parameterDoc != null)
                {
                    metadata.Parameters[parameter.Name] = parameterDoc.Value.Trim();
                }
            }

            return metadata;
        }