예제 #1
0
        public static DeclaredType Unresolved(TypeIdentifier typeIdentifier, Type declaration, Namespace ns)
        {
            var declaredType = new DeclaredType(typeIdentifier, ns)
            {
                IsResolved = false, declaration = declaration
            };

            if (declaration.BaseType != null)
            {
                declaredType.ParentType = Unresolved(
                    IdentifierFor.Type(declaration.BaseType),
                    declaration.BaseType,
                    Namespace.Unresolved(IdentifierFor.Namespace(declaration.BaseType.Namespace)));
            }

            IEnumerable <Type> interfaces = GetInterfaces(declaration);

            foreach (Type face in interfaces)
            {
                declaredType.Interfaces.Add(
                    Unresolved(IdentifierFor.Type(face), face, Namespace.Unresolved(IdentifierFor.Namespace(face.Namespace))));
            }

            return(declaredType);
        }
예제 #2
0
        protected static DeclaredType FindType(IDocumentationMember association, List <Namespace> namespaces)
        {
            var typeName   = IdentifierFor.Type(association.TargetType);
            var identifier = IdentifierFor.Namespace(association.TargetType.Namespace);

            return(namespaces.Find(x => x.IsIdentifiedBy(identifier)).Types.FirstOrDefault(x => x.IsIdentifiedBy(typeName)));
        }
예제 #3
0
        public void Add(List <Namespace> namespaces, DocumentedMethod association)
        {
            if (association.Method == null)
            {
                return;
            }

            DeclaredType type = FindType(association, namespaces);

            DeclaredType methodReturnType = null;

            if (association.Method.MemberType == MemberTypes.Method)
            {
                methodReturnType = DeclaredType.Unresolved(
                    IdentifierFor.Type(((MethodInfo)association.Method).ReturnType),
                    ((MethodInfo)association.Method).ReturnType,
                    Namespace.Unresolved(IdentifierFor.Namespace(((MethodInfo)association.Method).ReturnType.Namespace)));
            }

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

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

            foreach (ParameterInfo parameter in association.Method.GetParameters())
            {
                DeclaredType reference = DeclaredType.Unresolved(
                    IdentifierFor.Type(parameter.ParameterType),
                    parameter.ParameterType,
                    Namespace.Unresolved(IdentifierFor.Namespace(parameter.ParameterType.Namespace)));
                var docParam = new MethodParameter(parameter.Name, parameter.IsOptional, parameter.DefaultValue, reference);


                ParseParamSummary(association, docParam);

                doc.AddParameter(docParam);
            }

            if (_matchedAssociations.ContainsKey(association.Name))
            {
                return; // weird case when a type has the same method declared twice
            }

            _matchedAssociations.Add(association.Name, doc);

            if (type == null)
            {
                return;
            }

            type.AddMethod(doc);
        }
예제 #4
0
        public void ShouldBuildNamespaces()
        {
            var model   = new DocumentationModelBuilder(StubParser, new EventAggregator());
            var members = new[]
            {
                Type <First>(@"<member name=""T:Example.First"" />"),
                Type <DeepFirst>(@"<member name=""T:Example.Deep.DeepFirst"" />"),
            };
            var namespaces = model.CombineToTypeHierarchy(members);

            namespaces.ShouldContain(x => x.IsIdentifiedBy(IdentifierFor.Namespace("Example")));
            namespaces.ShouldContain(x => x.IsIdentifiedBy(IdentifierFor.Namespace("Example.Deep")));
        }
예제 #5
0
        public void Add(List <Namespace> namespaces, IDocumentationMember association)
        {
            if (association.TargetType.Namespace == null)
            {
                throw new NullReferenceException(
                          string.Format("There was no namespace found for {0}", association.TargetType.AssemblyQualifiedName));
            }

            NamespaceIdentifier ns = IdentifierFor.Namespace(association.TargetType.Namespace);

            if (!namespaces.Exists(x => x.IsIdentifiedBy(ns)))
            {
                Namespace doc = Namespace.Unresolved(ns);
                _matchedAssociations.Add(association.Name.CloneAsNamespace(), doc);
                namespaces.Add(doc);
            }
        }
예제 #6
0
        public void Add(List <Namespace> namespaces, DocumentedProperty association)
        {
            if (association.Property == null)
            {
                return;
            }

            DeclaredType type               = FindType(association, namespaces);
            var          isStatic           = association.Property.GetGetMethod().IsStatic;
            DeclaredType propertyReturnType =
                DeclaredType.Unresolved(
                    IdentifierFor.Type(association.Property.PropertyType),
                    association.Property.PropertyType,
                    Namespace.Unresolved(IdentifierFor.Namespace(association.Property.PropertyType.Namespace)));
            Property doc = Property.Unresolved(
                IdentifierFor.Property(association.Property, association.TargetType, isStatic),
                type,
                association.Property,
                propertyReturnType);

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

            if (_matchedAssociations.ContainsKey(association.Name))
            {
                return;
            }

            _matchedAssociations.Add(association.Name, doc);
            if (type == null)
            {
                return;
            }

            type.AddProperty(doc);
        }
예제 #7
0
        public void Add(List <Namespace> namespaces, DocumentedField association)
        {
            if (association.Field == null)
            {
                return;
            }

            DeclaredType type = FindType(association, namespaces);

            DeclaredType returnType = DeclaredType.Unresolved(
                IdentifierFor.Type(association.Field.FieldType),
                association.Field.FieldType,
                Namespace.Unresolved(IdentifierFor.Namespace(association.Field.FieldType.Namespace)));
            Field doc = Field.Unresolved(
                IdentifierFor.Field(association.Field, association.TargetType), type, returnType);

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

            _matchedAssociations.Add(association.Name, doc);
            type.AddField(doc);
        }
예제 #8
0
        protected static Namespace FindNamespace(IDocumentationMember association, List <Namespace> namespaces)
        {
            NamespaceIdentifier identifier = IdentifierFor.Namespace(association.TargetType.Namespace);

            return(namespaces.Find(x => x.IsIdentifiedBy(identifier)));
        }
예제 #9
0
 protected Namespace Namespace(string ns)
 {
     return(new Namespace(IdentifierFor.Namespace(ns)));
 }
 protected static DeclaredType Type <T>()
 {
     return(new DeclaredType(IdentifierFor.Type(typeof(T)), Namespace.Unresolved(IdentifierFor.Namespace(typeof(T).Namespace))));
 }
예제 #11
0
 public static Namespace to_namespace(this string ns)
 {
     return(new Namespace(IdentifierFor.Namespace(ns)));
 }