Beispiel #1
0
        protected override ChangeType CompareInstance(ICanCompare previous, bool suppressBreakingChanges)
        {
            ChangeType change = base.CompareInstance(previous, suppressBreakingChanges);

            MethodDetail other = (MethodDetail)previous;

            if (string.Compare(_body, other._body) != 0)
            {
                change |= ChangeType.ImplementationChanged;
            }

            return(change);
        }
        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();
        }
Beispiel #3
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();
        }
Beispiel #4
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();
        }
Beispiel #5
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();
        }