示例#1
0
        private bool ProcessMethodOnType(Dictionary <Assembly, XDocument> xmlDocs, RpcMethodInfo rpcMethodInfo, Type type)
        {
            var method = type.GetMethod(rpcMethodInfo.Method.MethodName);

            if (method != null)
            {
                var methodFullName = "M:" + method.DeclaringType.FullName + "." + method.Name;

                var xdoc = GetDocumentForAssembly(xmlDocs, method.DeclaringType.GetTypeInfo().Assembly);

                if (xdoc != null)
                {
                    var membersNode = xdoc.Descendants("members");

                    foreach (var element in membersNode.Descendants("member"))
                    {
                        var name = element.Attribute("name");

                        if (name != null && name.Value.StartsWith(methodFullName))
                        {
                            return(ExtractMethodDocumentation(element, rpcMethodInfo));
                        }
                    }
                }
            }

            return(false);
        }
示例#2
0
        private bool ExtractMethodDocumentation(XElement element, RpcMethodInfo method)
        {
            var summary = element.Descendants("summary").FirstOrDefault();

            if (summary == null)
            {
                return(false);
            }

            method.Comments = summary.Value?.Trim('\n', ' ');

            var parameters = element.Descendants("param");

            foreach (var parameterElement in parameters)
            {
                var paramName = parameterElement.Attribute("name");

                if (paramName != null)
                {
                    var paramDocNode =
                        method.Parameters.FirstOrDefault(p => p.Name == paramName.Value);

                    if (paramDocNode != null)
                    {
                        paramDocNode.Comments = parameterElement.Value?.Trim('\n', ' ');
                    }
                }
            }

            method.ReturnComment = element.Descendants("returns").FirstOrDefault()?.Value;

            return(true);
        }
示例#3
0
        private void ProcessInheritedDocumentation(Dictionary <Assembly, XDocument> xmlDocs, RpcMethodInfo rpcMethodInfo)
        {
            var currentType = rpcMethodInfo.Method.MethodInfo.DeclaringType.GetTypeInfo().BaseType;
            var processed   = false;

            while (processed == false && currentType != typeof(object))
            {
                currentType = currentType.GetTypeInfo().BaseType;
                processed   = ProcessMethodOnType(xmlDocs, rpcMethodInfo, currentType);
            }

            if (!processed)
            {
                foreach (var implementedInterface in
                         rpcMethodInfo.Method.MethodInfo.DeclaringType.GetTypeInfo().ImplementedInterfaces)
                {
                    if (ProcessMethodOnType(xmlDocs, rpcMethodInfo, implementedInterface))
                    {
                        break;
                    }
                }
            }
        }