示例#1
0
        public void Add(List <Namespace> namespaces, DocumentedEnum association)
        {
            if (association.Member == null)
            {
                return;
            }

            DeclaredType type = FindType(association, namespaces);

            var doc = Enumeration.Unresolved(
                IdentifierFor.Enum(association.Member, association.TargetType), type);

            //var evalue = Enum.Parse(association.Value.GetType(), association.Value.ToString());
            if (association.Value is uint)
            {
                doc.EnumValue = "0x" + ((uint)association.Value).ToString("X");
            }
            if (association.Value is int)
            {
                doc.EnumValue = ((int)association.Value).ToString();
            }

            ParseSummary(association, doc);
            ParseRemarks(association, doc);
            ParseExample(association, doc);

            _matchedAssociations[association.Name] = doc;
            type.AddEnum(doc);
        }
示例#2
0
        public static IEnumerable <IDocumentationMember> ReflectMembersForDocumenting(IEnumerable <Type> types)
        {
            foreach (var type in types)
            {
                if (type.IsSpecialName)
                {
                    continue;
                }
                if (type.Name.StartsWith("__"))
                {
                    continue;                             // probably a lambda generated class
                }
                yield return(new ReflectedType(IdentifierFor.Type(type), type));

                foreach (var method in type.GetMethods())
                {
                    if (method.IsSpecialName || (method.DeclaringType != null && method.DeclaringType.Name.Equals("Object")))
                    {
                        continue; //skip object base methods and special names
                    }
                    yield return(new ReflectedMethod(IdentifierFor.Method(method, type), method, type));
                }

                foreach (var constructor in type.GetConstructors())
                {
                    yield return(new ReflectedMethod(IdentifierFor.Method(constructor, type), constructor, type));
                }

                foreach (var property in type.GetProperties(BindingFlags.Static | BindingFlags.Public))
                {
                    yield return(new ReflectedProperty(IdentifierFor.Property(property, type, true), property, type, true));
                }
                foreach (var property in type.GetProperties(BindingFlags.Instance | BindingFlags.Public))
                {
                    yield return(new ReflectedProperty(IdentifierFor.Property(property, type, false), property, type, false));
                }

                foreach (var ev in type.GetEvents())
                {
                    yield return(new ReflectedEvent(IdentifierFor.Event(ev, type), ev, type));
                }

                if (type.IsEnum)
                {
                    foreach (var member in type.GetMembers(BindingFlags.Static | BindingFlags.Public))
                    {
                        yield return(new ReflectedEnum(IdentifierFor.Enum(member, type), member, type));
                    }
                }
                else
                {
                    foreach (var field in type.GetFields())
                    {
                        yield return(new ReflectedField(IdentifierFor.Field(field, type), field, type));
                    }
                }
            }
        }