Example #1
0
        public EnumDetail(RootDetail parent, Type type)
            : base(parent, type)
        {
            _visibility = VisibilityUtil.GetVisibilityFor(type);
            _category = "enum";

            foreach (string name in Enum.GetNames(type))
            {
                _children.Add(
                    new EnumItemDetail(
                        this,
                        name,
                        Convert.ToInt64(
                            type.GetField(name, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static)
                                .GetRawConstantValue()),
                        _visibility));
            }

            CodeStringBuilder csb = new CodeStringBuilder();

            AppendAttributesDeclaration(csb);

            csb.Mode = AppendMode.Html;
            csb.AppendVisibility(_visibility);
            csb.AppendText(" ");
            csb.Mode = AppendMode.Both;

            csb.AppendKeyword("enum ");
            csb.AppendText(type.Name);

            csb.Mode = AppendMode.Html;
            csb.AppendNewline();
            csb.AppendText("{");
            csb.AppendNewline();

            foreach (EnumItemDetail eid in FilterChildren<EnumItemDetail>())
            {
                csb.AppendIndent();
                csb.AppendText(eid.GetHtmlDeclaration());
                csb.AppendText(",");
                csb.AppendNewline();
            }

            csb.RemoveCharsFromEnd("<br>".Length);
            csb.RemoveCharsFromEnd(",".Length);
            csb.AppendNewline();
            csb.AppendText("}");
            csb.Mode = AppendMode.Both;

            _declaration = csb.ToString();
            _declarationHtml = csb.ToHtmlString();
        }
Example #2
0
        public PropertyDetail(RootDetail parent, PropertyInfo pi)
            : base(parent, pi)
        {
            _name = pi.Name;
            _category = "property";

            MethodInfo[] methods = pi.GetAccessors(true);
            foreach (MethodInfo mi in methods)
            {
                MethodDetail m = new MethodDetail(this, mi);

                if ((m.Name.Length > 3) && (mi.IsSpecialName))
                {
                    m.Name = m.Name.Substring(0, 3);
                }

                m.Declaration = null;
                _children.Add(m);
            }

            if (pi.GetIndexParameters().Length > 0)
            {
                CodeStringBuilder csbParameters = new CodeStringBuilder(AppendMode.Text);

                foreach (ParameterInfo ip in pi.GetIndexParameters())
                {
                    csbParameters.AppendParameterType(ip);
                    csbParameters.AppendText(", ");

                    _parameterCount++;
                }

                csbParameters.RemoveCharsFromEnd(2);

                _parameterTypesList = csbParameters.ToString();
            }

            _visibility = VisibilityUtil.GetMostVisible(FilterChildren<MethodDetail>());

            CodeStringBuilder csb = new CodeStringBuilder();

            AppendAttributesDeclaration(csb);

            csb.Mode = AppendMode.Html;
            csb.AppendVisibility(_visibility);
            csb.AppendText(" ");
            csb.Mode = AppendMode.Both;

            csb.AppendType(pi.PropertyType);
            csb.AppendText(" ");
            csb.AppendText(pi.Name);

            if (this.ParameterCount > 0)
            {
                csb.AppendText("[");
                csb.AppendText(this.ParameterTypesList);
                csb.AppendText("]");
            }

            csb.Mode = AppendMode.Html;

            csb.AppendNewline();
            csb.AppendText("{");
            csb.AppendNewline();
            csb.AppendIndent();

            foreach (MethodDetail mi in FilterChildren<MethodDetail>())
            {
                if (mi.Visibility != _visibility)
                {
                    csb.AppendVisibility(mi.Visibility);
                    csb.AppendText(" ");
                }

                csb.AppendText(mi.Name);
                csb.AppendText("; ");
            }

            csb.AppendNewline();
            csb.AppendText("}");

            _declaration = csb.ToString();
            _declarationHtml = csb.ToHtmlString();
        }
Example #3
0
        protected virtual void AppendAttributesDeclaration(CodeStringBuilder csb)
        {
            AppendMode oldMode = csb.Mode;
            csb.Mode = AppendMode.Html;

            foreach (AttributeDetail ad in FilterChildren<AttributeDetail>())
            {
                csb.AppendText("[");
                csb.AppendRawHtml(ad.GetHtmlDeclaration());
                csb.AppendText("]");
                csb.AppendNewline();
            }

            csb.Mode = oldMode;
        }