Example #1
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));
                    }
                }
            }
        }
        public void should_match_event()
        {
            var undocumentedMembers = DocumentableMemberFinder.ReflectMembersForDocumenting(new[] { typeof(First), typeof(Second), typeof(Third) });
            var snippets            = new[] { @"<member name=""E:Example.Second.AnEvent"" />".ToNode() };
            var members             = DocumentationXmlMatcher.MatchDocumentationToMembers(undocumentedMembers, snippets);
            var ev = Event <Second>("AnEvent");

            var member = members.FirstOrDefault(x => x.Name == IdentifierFor.Event(ev, typeof(Second))) as DocumentedEvent;

            member.ShouldNotBeNull();
            member.Xml.ShouldEqual(snippets[0]);
            member.Event.ShouldEqual(ev);
        }
Example #3
0
        public void ShouldHaveEventsInTypes()
        {
            var model   = new DocumentationModelBuilder(StubParser, new EventAggregator());
            var members = new IDocumentationMember[]
            {
                Type <Second>(@"<member name=""T:Example.Second"" />"),
                Event <Second>(@"<member name=""E:Example.Second.AnEvent"" />", "AnEvent"),
            };
            var namespaces = model.CombineToTypeHierarchy(members);
            var ev         = typeof(Second).GetEvent("AnEvent");

            namespaces[0].Types[0].Events.ShouldContain(x => x.IsIdentifiedBy(IdentifierFor.Event(ev, typeof(Second))));
        }
Example #4
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)
                    {
                        continue;
                    }

                    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())
                {
                    yield return(new ReflectedProperty(IdentifierFor.Property(property, type), property, type));
                }

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

                foreach (var field in type.GetFields())
                {
                    yield return(new ReflectedField(IdentifierFor.Field(field, type), field, type));
                }
            }
        }
Example #5
0
        public void Add(List <Namespace> namespaces, DocumentedEvent association)
        {
            if (association.Event == null)
            {
                return;
            }

            DeclaredType type = FindType(association, namespaces);

            Event doc = Event.Unresolved(IdentifierFor.Event(association.Event, association.TargetType), type);

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

            _matchedAssociations.Add(association.Name, doc);
            type.AddEvent(doc);
        }
        protected DocumentedEvent Event <T>(string xml, string eventName)
        {
            var ev = typeof(T).GetEvent(eventName);

            return(new DocumentedEvent(IdentifierFor.Event(ev, typeof(T)), xml.ToNode(), ev, typeof(T)));
        }
 protected static Event Event <T>(string name)
 {
     return(new Event(IdentifierFor.Event(typeof(T).GetEvent(name), typeof(T)), Type <T>()));
 }
 private IDocumentationMember find_event <T>(string name)
 {
     return(members.FirstOrDefault(x => x.Name == IdentifierFor.Event(typeof(T).GetEvent(name), typeof(T))));
 }