/// <summary>
        ///   Visit the generic base class <see cref="T:NuDoq.Member" />.
        /// </summary>
        /// 
        /// <remarks>
        ///   This method is called for all <see cref="T:NuDoq.Member" />-derived types.
        /// </remarks>
        /// 
        public override void VisitMember(Member member)
        {
            if (member.Kind.HasFlag(MemberKinds.Class))
            {
                this.currentClassName = member.Info.Name;
                current = new DocumentationViewModel();
                Texts[currentClassName] = current;

                builder = new StringBuilder();
                insideTextBlock = false;

                base.VisitMember(member);
            }
        }
Пример #2
0
 public override void VisitMember(Member member)
 {
     var info = member.Info;
       var signature = String.Empty;
       if (info is MethodBase) {
     var method = (MethodBase)info;
     if (!method.IsPublic && !method.IsFamily) {
       // Ignore methods other than public and protected
       // methods
       return;
     }
     using (var ch = this.AddMember(info)) {
       signature = FormatMethod(method);
       this.WriteLine("### " + Heading(info) +
             "\r\n\r\n" + signature + "\r\n\r\n");
       var attr = method.GetCustomAttribute(typeof(ObsoleteAttribute)) as
     ObsoleteAttribute;
       if (attr != null) {
     this.WriteLine("<b>Deprecated.</b> " + attr.Message + "\r\n\r\n");
       }
       this.paramStr.Clear();
       this.returnStr.Clear();
       this.exceptionStr.Clear();
       base.VisitMember(member);
       if (this.paramStr.Length > 0) {
     this.Write("<b>Parameters:</b>\r\n\r\n");
     var paramString = this.paramStr.ToString();
     // Decrease spacing between list items
     paramString = paramString.Replace("\r\n * ", " * ");
     this.Write(paramString);
       }
       this.Write(this.returnStr.ToString());
       if (this.exceptionStr.Length > 0) {
     this.Write("<b>Exceptions:</b>\r\n\r\n");
     this.Write(this.exceptionStr.ToString());
       }
     }
       } else if (info is Type) {
     var type = (Type)info;
     if (!type.IsPublic) {
       // Ignore nonpublic types
       return;
     }
     using (var ch = this.AddMember(info)) {
       this.WriteLine("## " + Heading(type) + "\r\n\r\n");
       this.WriteLine(FormatTypeSig(type) + "\r\n\r\n");
       var attr = type.GetCustomAttribute(typeof(ObsoleteAttribute)) as
     ObsoleteAttribute;
       if (attr != null) {
     this.WriteLine("<b>Deprecated.</b> " + attr.Message + "\r\n\r\n");
       }
       this.paramStr.Clear();
       base.VisitMember(member);
       if (this.paramStr.Length > 0) {
     this.Write("<b>Parameters:</b>\r\n\r\n");
     var paramString = this.paramStr.ToString();
     // Decrease spacing between list items
     paramString = paramString.Replace("\r\n * ", " * ");
     this.Write(paramString);
       }
     }
       } else if (info is PropertyInfo) {
     var property = (PropertyInfo)info;
     if (!PropertyIsPublicOrFamily(property)) {
       // Ignore methods other than public and protected
       // methods
       return;
     }
     using (var ch = this.AddMember(info)) {
       signature = FormatProperty(property);
       this.WriteLine("### " + property.Name + "\r\n\r\n" + signature +
             "\r\n\r\n");
       var attr = property.GetCustomAttribute(typeof(ObsoleteAttribute)) as
     ObsoleteAttribute;
       if (attr != null) {
     this.WriteLine("<b>Deprecated.</b> " + attr.Message + "\r\n\r\n");
       }
       this.paramStr.Clear();
       this.returnStr.Clear();
       this.exceptionStr.Clear();
       base.VisitMember(member);
       if (this.paramStr.Length > 0) {
     this.Write("<b>Parameters:</b>\r\n\r\n");
     this.Write(this.paramStr.ToString());
       }
       this.Write(this.returnStr.ToString());
       if (this.exceptionStr.Length > 0) {
     this.Write("<b>Exceptions:</b>\r\n\r\n");
     this.Write(this.exceptionStr.ToString());
       }
     }
       } else if (info is FieldInfo) {
     var field = (FieldInfo)info;
     if (!field.IsPublic && !field.IsFamily) {
       // Ignore nonpublic, nonprotected fields
       return;
     }
     using (var ch = this.AddMember(info)) {
       signature = FormatField(field);
       this.WriteLine("### " + field.Name + "\r\n\r\n" + signature +
             "\r\n\r\n");
       base.VisitMember(member);
     }
       }
 }
Пример #3
0
        /// <summary>
        /// See <see cref="Visitor.VisitMember"/>.
        /// </summary>
        public override void VisitMember(Member member)
        {
            if (delegates.VisitMember != null)
                delegates.VisitMember(member);

            base.VisitMember(member);
        }
Пример #4
0
        /// <summary>
        /// Sets the extended reflection info if found in the map.
        /// </summary>
        private static Member SetInfo(Member member, MemberIdMap map)
        {
            member.Info = map.FindMember(member.Id);

            return member;
        }
Пример #5
0
        /// <summary>
        /// Replaces the generic <see cref="TypeDeclaration"/> with 
        /// concrete types according to the reflection information.
        /// </summary>
        private static Member ReplaceTypes(Member member, MemberIdMap map)
        {
            if (member.Kind != MemberKinds.Type)
                return member;

            var type = (Type)map.FindMember(member.Id);
            if (type == null)
                return member;

            if (type.IsInterface)
                return new Interface(member.Id, member.Elements);
            if (type.IsClass)
                return new Class(member.Id, member.Elements);
            if (type.IsEnum)
                return new Enum(member.Id, member.Elements);
            if (type.IsValueType)
                return new Struct(member.Id, member.Elements);

            return member;
        }
Пример #6
0
        /// <summary>
        /// Replaces the generic method element with a more specific extension method 
        /// element as needed.
        /// </summary>
        /// <param name="member">The member.</param>
        /// <param name="map">The map.</param>
        /// <returns></returns>
        private static Member ReplaceExtensionMethods(Member member, MemberIdMap map)
        {
            if (member.Kind != MemberKinds.Method)
                return member;

            var method = (MethodBase)map.FindMember(member.Id);
            if (method == null)
                return member;

            if (method.GetCustomAttributes(true).Any(attr => attr.GetType().FullName == "System.Runtime.CompilerServices.ExtensionAttribute"))
            {
                var extendedTypeId = map.FindId(method.GetParameters()[0].ParameterType);
                if (!string.IsNullOrEmpty(extendedTypeId))
                    return new ExtensionMethod(member.Id, extendedTypeId, member.Elements);
            }

            return member;
        }
Пример #7
0
 /// <summary>
 /// Visit the generic base class <see cref="Member"/>.
 /// </summary>
 /// <remarks>
 /// This method is called for all <see cref="Member"/>-derived 
 /// types.
 /// </remarks>
 public virtual void VisitMember(Member member)
 {
     VisitContainer(member);
 }