GetNestedTypes() public method

public GetNestedTypes ( ) : Type[]
return Type[]
コード例 #1
0
ファイル: outline.cs プロジェクト: samcf111/unityMono5.5.0
        public void OutlineType()
        {
            bool first;

            OutlineAttributes();
            o.Write(GetTypeVisibility(t));

            if (t.IsClass && !t.IsSubclassOf(type_multicast_delegate))
            {
                if (t.IsSealed)
                {
                    o.Write(t.IsAbstract ? " static" : " sealed");
                }
                else if (t.IsAbstract)
                {
                    o.Write(" abstract");
                }
            }

            o.Write(" ");
            o.Write(GetTypeKind(t));
            o.Write(" ");

            Type [] interfaces = (Type [])Comparer.Sort(TypeGetInterfaces(t, declared_only));
            Type    parent     = t.BaseType;

            if (t.IsSubclassOf(type_multicast_delegate))
            {
                MethodInfo method;

                method = t.GetMethod("Invoke");

                o.Write(FormatType(method.ReturnType));
                o.Write(" ");
                o.Write(GetTypeName(t));
                o.Write(" (");
                OutlineParams(method.GetParameters());
                o.Write(")");

                WriteGenericConstraints(t.GetGenericArguments());

                o.WriteLine(";");
                return;
            }

            o.Write(GetTypeName(t));
            if (((parent != null && parent != type_object && parent != type_value_type) || interfaces.Length != 0) && !t.IsEnum)
            {
                first = true;
                o.Write(" : ");

                if (parent != null && parent != type_object && parent != type_value_type)
                {
                    o.Write(FormatType(parent));
                    first = false;
                }

                foreach (Type intf in interfaces)
                {
                    if (!first)
                    {
                        o.Write(", ");
                    }
                    first = false;

                    o.Write(FormatType(intf));
                }
            }

            if (t.IsEnum)
            {
                Type underlyingType = t.GetEnumUnderlyingType();
                if (underlyingType != type_int)
                {
                    o.Write(" : {0}", FormatType(underlyingType));
                }
            }
            WriteGenericConstraints(t.GetGenericArguments());
            o.WriteLine(" {");
            o.Indent++;

            if (t.IsEnum)
            {
                bool is_first = true;
                foreach (FieldInfo fi in t.GetFields(BindingFlags.Public | BindingFlags.Static))
                {
                    if (!is_first)
                    {
                        o.WriteLine(",");
                    }
                    is_first = false;
                    o.Write(fi.Name);
                }
                o.WriteLine();
                o.Indent--; o.WriteLine("}");
                return;
            }

            first = true;

            foreach (ConstructorInfo ci in t.GetConstructors(DefaultFlags))
            {
                if (!ShowMember(ci))
                {
                    continue;
                }

                if (first)
                {
                    o.WriteLine();
                }
                first = false;

                OutlineMemberAttribute(ci);
                OutlineConstructor(ci);

                o.WriteLine();
            }


            first = true;

            foreach (MethodInfo m in Comparer.Sort(t.GetMethods(DefaultFlags)))
            {
                if (!ShowMember(m))
                {
                    continue;
                }

                if ((m.Attributes & MethodAttributes.SpecialName) != 0)
                {
                    continue;
                }

                if (first)
                {
                    o.WriteLine();
                }
                first = false;

                OutlineMemberAttribute(m);
                OutlineMethod(m);

                o.WriteLine();
            }

            first = true;

            foreach (MethodInfo m in t.GetMethods(DefaultFlags))
            {
                if (!ShowMember(m))
                {
                    continue;
                }

                if ((m.Attributes & MethodAttributes.SpecialName) == 0)
                {
                    continue;
                }
                if (!(m.Name.StartsWith("op_")))
                {
                    continue;
                }

                if (first)
                {
                    o.WriteLine();
                }
                first = false;

                OutlineMemberAttribute(m);
                OutlineOperator(m);

                o.WriteLine();
            }

            first = true;

            foreach (PropertyInfo pi in Comparer.Sort(t.GetProperties(DefaultFlags)))
            {
                if (!((pi.CanRead && ShowMember(pi.GetGetMethod(true))) ||
                      (pi.CanWrite && ShowMember(pi.GetSetMethod(true)))))
                {
                    continue;
                }

                if (first)
                {
                    o.WriteLine();
                }
                first = false;

                OutlineMemberAttribute(pi);
                OutlineProperty(pi);

                o.WriteLine();
            }

            first = true;

            foreach (FieldInfo fi in t.GetFields(DefaultFlags))
            {
                if (!ShowMember(fi))
                {
                    continue;
                }

                if (first)
                {
                    o.WriteLine();
                }
                first = false;

                OutlineMemberAttribute(fi);
                OutlineField(fi);

                o.WriteLine();
            }

            first = true;

            foreach (EventInfo ei in Comparer.Sort(t.GetEvents(DefaultFlags)))
            {
                if (!ShowMember(ei.GetAddMethod(true)))
                {
                    continue;
                }

                if (first)
                {
                    o.WriteLine();
                }
                first = false;

                OutlineMemberAttribute(ei);
                OutlineEvent(ei);

                o.WriteLine();
            }

            first = true;

            foreach (Type ntype in Comparer.Sort(t.GetNestedTypes(DefaultFlags)))
            {
                if (!ShowMember(ntype))
                {
                    continue;
                }

                if (first)
                {
                    o.WriteLine();
                }
                first = false;

#if STATIC
                new Outline(universe, mscorlib, ntype, o, declared_only, show_private, filter_obsolete).OutlineType();
#else
                new Outline(ntype, o, declared_only, show_private, filter_obsolete).OutlineType();
#endif
            }

            o.Indent--; o.WriteLine("}");
        }