Esempio n. 1
0
        public EntityDetail(RootDetail parent, Type type, bool takeVisibilityFromParent)
            : base(parent, type)
        {
            _visibility = VisibilityUtil.GetVisibilityFor(type);

            BindingFlags flags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;

            List <MethodBase> methods = FilterMethods(type.GetMethods(flags), type, false);

            foreach (MethodBase mi in methods)
            {
                MethodDetail md = new MethodDetail(this, mi);

                if (takeVisibilityFromParent)
                {
                    md.Visibility = _visibility;
                }

                _children.Add(md);
            }

            List <MethodBase> constructors = FilterMethods(type.GetConstructors(flags), type, false);

            foreach (MethodBase mi in constructors)
            {
                MethodDetail md = new MethodDetail(this, mi);

                if (takeVisibilityFromParent)
                {
                    md.Visibility = _visibility;
                }

                _children.Add(md);
            }

            List <MethodBase> operators = FilterMethods(type.GetMethods(flags), type, true);

            foreach (MethodBase mi in operators)
            {
                OperatorDetail od = new OperatorDetail(this, mi);

                if (takeVisibilityFromParent)
                {
                    od.Visibility = _visibility;
                }

                _children.Add(od);
            }

            List <PropertyInfo> props = FilterProperties(type.GetProperties(flags), type);

            foreach (PropertyInfo pi in props)
            {
                PropertyDetail pd = new PropertyDetail(this, pi);

                if (takeVisibilityFromParent)
                {
                    pd.Visibility = _visibility;
                }

                _children.Add(pd);
            }

            List <EventInfo> events = FilterEvents(type.GetEvents(flags), type);

            foreach (EventInfo ei in events)
            {
                EventDetail ed = new EventDetail(this, ei);

                if (takeVisibilityFromParent)
                {
                    ed.Visibility = _visibility;
                }

                _children.Add(ed);
            }

            List <FieldInfo> fields = FilterFields(type.GetFields(flags), type);

            foreach (FieldInfo fi in fields)
            {
                FieldDetail fd = new FieldDetail(this, fi);

                if (takeVisibilityFromParent)
                {
                    fd.Visibility = _visibility;
                }

                _children.Add(fd);
            }

            CodeStringBuilder csb = new CodeStringBuilder();

            AppendAttributesDeclaration(csb);

            csb.Mode = AppendMode.NonText;
            csb.AppendVisibility(_visibility);
            csb.AppendText(" ");
            csb.Mode = AppendMode.All;

            if (type.IsAbstract && type.IsSealed)
            {
                csb.AppendKeyword("static ");
            }
            else if (type.IsInterface)
            {
                csb.AppendKeyword("interface ");
            }
            else if (type.IsAbstract)
            {
                csb.AppendKeyword("abstract ");
            }
            else if (type.IsSealed)
            {
                csb.AppendKeyword("sealed ");
            }

            if (type.IsClass)
            {
                csb.AppendKeyword("class ");
            }

            csb.AppendText(_name);

            csb.AppendBaseClasses(type);

            csb.AppendGenericRestrictions(type);

            _declaration         = csb.ToString();
            _declarationHtml     = csb.ToHtmlString();
            _declarationMarkdown = csb.ToMarkdownString();
        }
Esempio n. 2
0
        public EntityDetail(RootDetail parent, Type type, bool takeVisibilityFromParent)
            : base(parent, type)
        {
            _visibility = VisibilityUtil.GetVisibilityFor(type);

            BindingFlags flags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;

            List<MethodBase> methods = FilterMethods(type.GetMethods(flags), type, false);
            foreach (MethodBase mi in methods)
            {
                MethodDetail md = new MethodDetail(this, mi);

                if (takeVisibilityFromParent)
                {
                    md.Visibility = _visibility;
                }

                _children.Add(md);
            }

            List<MethodBase> constructors = FilterMethods(type.GetConstructors(flags), type, false);
            foreach (MethodBase mi in constructors)
            {
                MethodDetail md = new MethodDetail(this, mi);

                if (takeVisibilityFromParent)
                {
                    md.Visibility = _visibility;
                }

                _children.Add(md);
            }

            List<MethodBase> operators = FilterMethods(type.GetMethods(flags), type, true);
            foreach (MethodBase mi in operators)
            {
                OperatorDetail od = new OperatorDetail(this, mi);

                if (takeVisibilityFromParent)
                {
                    od.Visibility = _visibility;
                }

                _children.Add(od);
            }

            List<PropertyInfo> props = FilterProperties(type.GetProperties(flags), type);
            foreach (PropertyInfo pi in props)
            {
                PropertyDetail pd = new PropertyDetail(this, pi);

                if (takeVisibilityFromParent)
                {
                    pd.Visibility = _visibility;
                }

                _children.Add(pd);
            }

            List<EventInfo> events = FilterEvents(type.GetEvents(flags), type);
            foreach (EventInfo ei in events)
            {
                EventDetail ed = new EventDetail(this, ei);

                if (takeVisibilityFromParent)
                {
                    ed.Visibility = _visibility;
                }

                _children.Add(ed);
            }

            List<FieldInfo> fields = FilterFields(type.GetFields(flags), type);
            foreach (FieldInfo fi in fields)
            {
                FieldDetail fd = new FieldDetail(this, fi);

                if (takeVisibilityFromParent)
                {
                    fd.Visibility = _visibility;
                }

                _children.Add(fd);
            }

            CodeStringBuilder csb = new CodeStringBuilder();

            AppendAttributesDeclaration(csb);

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

            if (type.IsAbstract && type.IsSealed)
            {
                csb.AppendKeyword("static ");
            }
            else if (type.IsInterface)
            {
                csb.AppendKeyword("interface ");
            }
            else if (type.IsAbstract)
            {
                csb.AppendKeyword("abstract ");
            }
            else if (type.IsSealed)
            {
                csb.AppendKeyword("sealed ");
            }

            if (type.IsClass)
            {
                csb.AppendKeyword("class ");
            }

            csb.AppendText(_name);

            csb.AppendBaseClasses(type);

            csb.AppendGenericRestrictions(type);

            _declaration = csb.ToString();
            _declarationHtml = csb.ToHtmlString();
        }