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));
		}
示例#2
0
		static string GetMemberName(MemberDom member)
		{
			if (member is ConstructorDom)
				return null;
			else
				return "." + member.Name;
		}
		static string Generate(MemberDom member)
		{
			XElement body;
			var doc = GetDoc(out 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();
		}
示例#4
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();
		}
示例#5
0
        public static TypeDom Build(TypeDoc doc, AssemblyDom asm, Func <MemberDom, bool> filterMembers)
        {
            var ret = new TypeDom
            {
                Assembly = asm,
                DocInfo  = doc.DocInfo,
                Type     = doc.ReflectionType,
            };

            MemberDom[] members = doc.Members
                                  .Where(_ => _.ReflectionMemberInfo != null)
                                  .Select(_ => MemberDom.Build(ret, _.ReflectionMemberInfo, _.DocInfo))
                                  .ToArray();

            members = members.Where(
                _ => (filterMembers == null || filterMembers(_)) && !_.IsPrivateOrInternal
                ).ToArray();

            ret.AllMembers   = members;
            ret.Constructors = members.OfType <ConstructorDom>().OrderBy(_ => _.ShortSignature).ToArray();
            ret.Fields       = members.OfType <FieldDom>()
                               .OrderBy(_ => _.ShortSignature)
                               .ToArray();
            ret.Properties = members.OfType <PropertyDom>()
                             .OrderBy(_ => _.ShortSignature)
                             .ToArray();
            ret.Methods = members.OfType <MethodDom>()
                          .Where(_ => !_.IsOperator)
                          .OrderBy(_ => _.ShortSignature)
                          .ToArray();
            ret.Operators = members.OfType <MethodDom>()
                            .Where(_ => _.IsOperator)
                            .OrderBy(_ => _.ShortSignature)
                            .ToArray();
            ret.Events = members.OfType <EventDom>()
                         .OrderBy(_ => _.ShortSignature)
                         .ToArray();
            ret.GenericTypeParameters = GenericParameterDom.BuildTypeGenericParameters(ret.Type, ret.DocInfo);
            return(ret);
        }
		static XElement BuildMemberType(MemberDom m)
		{
			if (m.MemberType == null)
				return null;
			return x("span",
			         Names[Strings.Type] + ": ", BuildTypeUrl(m.MemberType)
				);
		}
		static XElement BuildReturns(MemberDom m)
		{
			var meth= m as MethodDom;
			if (meth == null)
				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)
				);
		}
示例#8
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;
		}
示例#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 IEnumerable<XElement> GetMemberIcons(MemberDom member)
		{
			MemberIconsEnum? memberType = null;
			string memberName="";
			if (member is ConstructorDom)
			{
				memberType = member.IsPublic ? MemberIconsEnum.MethodPub : MemberIconsEnum.MethodProt;
				memberName = "Method";
			}
			if (member is MethodDom)
			{
				var meth = (MethodDom) member;
				if (meth.IsOperator)
				{
					memberType = member.IsPublic ? MemberIconsEnum.OperatorPub : MemberIconsEnum.OperatorProt;
					memberName = "Operator";
				}
				else if (meth.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]);
		}
示例#12
0
		private static void AddMembers(OfflineDynamicPage parentNode, TypeDom type, MemberDom[] members, MemberTypeSection section)
		{
			if (members == null || members.Length == 0)
				return;

			var sectionItem = new OfflineDynamicPage
			{
				Parent = parentNode,
				UrlPart = parentNode.UrlPart + "/" + section.ToString(),
				RussianTitle = GenerateHtml.GetSectionName(section),
				RussianContent = GenerateHtml.Generate(new TypePartialData { SectionType = section, Type = type }),
			};

			if (section == MemberTypeSection.Methods || section == MemberTypeSection.ExtentionMethods)
				GenerateMethods((MethodDom[])members, sectionItem, parentNode.UrlPart);
			else
			{
				foreach (var member in members)
				{
					//ToDo: Группировка переопределенных методов.
					var memberItem = new OfflineDynamicPage
					{
						Parent = sectionItem,
						UrlPart = parentNode.UrlPart + "/" + member.SimpleName,
						RussianTitle = member.ShortSignature,
						RussianContent = GenerateHtml.Generate(member),
					};
					sectionItem.Childs.Add(memberItem);
				}
			}

			parentNode.Childs.Add(sectionItem);
		}
示例#13
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;
		}