Пример #1
0
 static string GetMethodKindName(MemberDom m)
 {
     if (m is MethodDom)
     {
         var meth = m as MethodDom;
         if (meth.IsOperator)
         {
             return(Strings.Operator);
         }
         else
         {
             return(Strings.Method);
         }
     }
     else if (m is ConstructorDom)
     {
         return(Strings.Constructor);
     }
     else if (m is EventDom)
     {
         return(Strings.Event);
     }
     else if (m is PropertyDom)
     {
         return(Strings.Property);
     }
     else if (m is FieldDom)
     {
         return(Strings.Field);
     }
     else
     {
         throw new Exception();
     }
 }
        private static IEnumerable <XElement> GetMemberIcons(MemberDom member)
        {
            MemberIconsEnum?memberType = null;
            var             memberName = "";

            if (member is ConstructorDom)
            {
                memberType = member.IsPublic ? MemberIconsEnum.MethodPub : MemberIconsEnum.MethodProt;
                memberName = "Method";
            }
            if (member is MethodDom method)
            {
                if (method.IsOperator)
                {
                    memberType = member.IsPublic ? MemberIconsEnum.OperatorPub : MemberIconsEnum.OperatorProt;
                    memberName = "Operator";
                }
                else if (method.IsExtention)
                {
                    if (!member.IsPublic)
                    {
                        throw new InvalidOperationException();
                    }

                    memberType = MemberIconsEnum.MethodExtPub;
                    memberName = "Extention";
                }
                else
                {
                    memberType = member.IsPublic ? MemberIconsEnum.MethodPub : MemberIconsEnum.MethodProt;
                    memberName = "Method";
                }
            }
            else if (member is PropertyDom)
            {
                memberType = member.IsPublic ? MemberIconsEnum.PropertyPub : MemberIconsEnum.PropertyProt;
                memberName = "Property";
            }
            else if (member is FieldDom)
            {
                memberType = member.IsPublic ? MemberIconsEnum.FieldPub : MemberIconsEnum.FieldProt;
                memberName = "Field";
            }
            else if (member is EventDom)
            {
                memberType = member.IsPublic ? MemberIconsEnum.EventPub : MemberIconsEnum.EventProt;
                memberName = "Event";
            }

            memberName += member.IsPublic ? "Pub" : "Prot";

            if (memberType != null)
            {
                yield return(GetImage(Navigation.GetIconCss(memberType.Value), Names[memberName], Navigation.EmptyImage, Names[memberName]));
            }
            if (member.IsStatic)
            {
                yield return(GetImage(Navigation.GetIconCss(MemberIconsEnum.Static), Names[Strings.StaticMember], Navigation.EmptyImage, Names[Strings.StaticMember]));
            }
        }
Пример #3
0
 static XElement BuildMemberType(MemberDom m)
 {
     if (m.MemberType == null)
     {
         return(null);
     }
     return(x("span",
              Names[Strings.Type] + ": ", BuildTypeUrl(m.MemberType)
              ));
 }
Пример #4
0
 static string GetMemberName(MemberDom member)
 {
     if (member is ConstructorDom)
     {
         return(null);
     }
     else
     {
         return("." + member.Name);
     }
 }
Пример #5
0
        static XElement BuildMemberUrl(MemberDom member, bool asExtention, bool showType = false)
        {
            var    ret  = x("a", GetShortSignature(member, asExtention, showType));
            string href = Navigation.GetMemberHref(member);

            if (!string.IsNullOrEmpty(href))
            {
                ret.Add(a("href", href));
            }
            return(ret);
        }
        static string GetShortSignature(MemberDom m, bool asExtention, bool showType = false)
        {
            if (!asExtention)
            {
                return(showType ? m.Type.Type.Name + "." + m.ShortSignature : m.ShortSignature);
            }

            if (m is MethodDom meth && meth.IsExtention)
            {
                return(meth.GetShortSignature(true));
            }
Пример #7
0
        public string GetMemberHref(MemberDom m)
        {
            var tuple = GetTypeHref(m.Type.Type);
            var ret   = tuple.Item1 + "/" + m.Name;

            if (m is MethodDom)
            {
                var meth = (MethodDom)m;
                if (meth.OverloadIndex.HasValue)
                {
                    ret += "/" + meth.OverloadIndex.ToString();
                }
            }
            return(ret);
        }
Пример #8
0
        static string Generate(MemberDom member)
        {
            var doc = GetDoc(out var body);

            body.Add(
                x("h1", member.Type.SimpleName + GetMemberName(member) + Names[Strings.SuffixDelimeter] +
                  Names[GetMethodKindName(member)] + " ", member.GetParametersLongSignature()),
                x("p", XMLUtils.GetTagInnerXml(member.DocInfo, "summary", Navigation, true)),
                NamespaceAssembly(member.DeclaringType),
                GenerateSyntax(member),
                BuldParameters(Names[Strings.TypeParameters], member.GenericArguments),
                BuldParameters(Names[Strings.Parameters], member.Params),
                BuildReturns(member),
                BuildEnding(member.Type.Assembly, member.DocInfo)
                );
            return(doc.ToString());
        }
Пример #9
0
        static string GetShortSignature(MemberDom m, bool asExtention, bool showType = false)
        {
            if (!asExtention)
            {
                return(showType ? m.Type.Type.Name + "." + m.ShortSignature : m.ShortSignature);
            }

            var meth = m as MethodDom;

            if (meth != null && meth.IsExtention)
            {
                return(meth.GetShortSignature(true));
            }
            else
            {
                return(m.ShortSignature);
            }
        }
Пример #10
0
        static XElement GetMemberDescription(MemberDom m)
        {
            var ret = XMLUtils.GetTagInnerXml(m.DocInfo, "summary", Navigation, false) ?? string.Empty.ToSpan();

            var inherited = m.GetInheritedFrom();
            var overrides = m.GetOverrides();

            if (overrides != null)
            {
                ret.Add((" (" + Names[Strings.Overrides] + " ").ToSpan(), BuildMemberUrl(overrides, false, true), ")".ToSpan());
            }
            else if (inherited != null)
            {
                ret.Add((" (" + Names[Strings.InheritedFrom] + " ").ToSpan(), BuildTypeUrl(inherited), ")".ToSpan());
            }

            return(ret);
        }
Пример #11
0
 static XElement BuildReturns(MemberDom m)
 {
     if (!(m is MethodDom meth))
     {
         return(BuildMemberType(m));
     }
     if (meth.MemberType == null || meth.MemberType == typeof(void))
     {
         return(null);
     }
     return
         (x("div",
            a("class", "doc_return"),
            x("h4", Names[Strings.ReturnValue], a("class", "doc_h4")),
            Names[Strings.Type] + ": ",
            BuildTypeUrl(meth.MemberType),
            x("br"),
            XMLUtils.GetTagInnerXml(m.DocInfo, "returns", Navigation, true)
            ));
 }
Пример #12
0
        private static XElement GenerateSyntax(MemberDom member)
        {
            var parts = new List <XElement> {
                x("span", member.IsPublic ? "public" : "protected", a("style", "color:Blue;"))
            };

            if (member.IsStatic)
            {
                parts.Add(x("span", "static", a("style", "color:Blue;")));
            }

            if (member.MemberType == typeof(void))
            {
                parts.Add(x("span", "void", a("style", "color:Blue;")));
            }

            parts.Add(x("span", member.Name));

            if (member.Params != null && member.Params.Length > 0)
            {
                parts.Add(x("span", "("));

                foreach (var param in member.Params)
                {
                    parts.Add(BuildTypeUrl(param.Type, false));

                    parts.Add(x("span", " " + param.Name));
                    parts.Add(x("span", ","));
                }

                parts.RemoveAt(parts.Count - 1);

                parts.Add(x("span", ")"));
            }

            return(x("div", a("class", "doc_syntax"), x("code", parts)));
        }