コード例 #1
0
ファイル: DocXmlReader.cs プロジェクト: jpeirson/DocXml
        /// <summary>
        /// Return Summary comments for specified type.
        /// For Delegate types Parameters field may be returned as well.
        /// </summary>
        /// <param name="type"></param>
        /// <returns>TypeComment</returns>
        public TypeComments GetTypeComments(Type type)
        {
            var comments = new TypeComments();
            var node     = GetXmlMemberNode(type.TypeId(), type);

            return(GetComments(type, comments, node));
        }
コード例 #2
0
ファイル: DocXmlReader.cs プロジェクト: jpeirson/DocXml
        private TypeComments ResolveInheritdocComments(TypeComments comments, Type type)
        {
            if (!NeedsResolving(comments) ||
                comments?.Parameters?.Count > 0)
            {
                return(comments);
            }

            // If an explicit cref attribute is specified, the documentation from
            // the specified namespace/type/member is inherited.
            if (GetCrefComments(comments.Inheritdoc.Cref, type, comments,
                                (node) => GetComments(type, comments, node)))
            {
                return(comments);
            }

            // For types and interfaces:
            // - Inherit documentation from all base classes working backwards up
            //   the inheritance chain.
            // - Inherit documentation from all interface implementations (if any)
            //   working through them in the order listed in the reflection information file (usually alphabetically).
            if (type.BaseType != null && type.BaseType != typeof(object))
            {
                var newComments = GetTypeComments(type.BaseType);
                if (newComments != null)
                {
                    newComments.Parameters = comments.Parameters;
                    newComments.Inheritdoc = comments.Inheritdoc;
                    return(newComments);
                }
            }

            var interfaces = type.GetInterfaces();

            if (interfaces?.Length > 0)
            {
                foreach (var intf in interfaces.OrderBy(i => i.FullName))
                {
                    var newComments = GetTypeComments(intf);
                    if (newComments != null)
                    {
                        newComments.Parameters = comments.Parameters;
                        newComments.Inheritdoc = comments.Inheritdoc;
                        return(newComments);
                    }
                }
            }

            return(comments);
        }
コード例 #3
0
ファイル: DocXmlReader.cs プロジェクト: jpeirson/DocXml
 protected TypeComments GetComments(Type type, TypeComments comments, XPathNavigator node)
 {
     if (node == null)
     {
         return(comments);
     }
     if (type.IsSubclassOf(typeof(Delegate)))
     {
         comments.Parameters = GetParametersComments(node);
     }
     GetCommonComments(comments, node);
     comments = ResolveInheritdocComments(comments, type);
     return(comments);
 }