Inheritance: IDocumentationMember
Exemplo n.º 1
0
        static void MatchMethod(List<IDocumentationMember> members, XmlNode node)
        {
            Identifier member = IdentifierFor.XmlString(node.Attributes["name"].Value);

            for (int i = 0; i < members.Count; i++)
            {
                var reflected = members[i] as ReflectedMethod;
                if (reflected != null && reflected.Match(member))
                    members[i] = new DocumentedMethod(reflected.Name, node, reflected.Method, reflected.TargetType);
            }
        }
Exemplo n.º 2
0
        public void Add(List<Namespace> namespaces, DocumentedMethod association)
        {
            if (association.Method == null)
            {
                return;
            }

            Namespace ns = this.FindNamespace(association, namespaces);
            DeclaredType type = this.FindType(ns, association);

            DeclaredType methodReturnType = DeclaredType.Unresolved(
                Identifier.FromType(association.Method.ReturnType),
                association.Method.ReturnType,
                Namespace.Unresolved(Identifier.FromNamespace(association.Method.ReturnType.Namespace)));
            Method doc = Method.Unresolved(
                Identifier.FromMethod(association.Method, association.TargetType),
                type,
                association.Method,
                methodReturnType);

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

            foreach (ParameterInfo parameter in association.Method.GetParameters())
            {
                DeclaredType reference = DeclaredType.Unresolved(
                    Identifier.FromType(parameter.ParameterType),
                    parameter.ParameterType,
                    Namespace.Unresolved(Identifier.FromNamespace(parameter.ParameterType.Namespace)));
                var docParam = new MethodParameter(parameter.Name, reference);

                this.ParseParamSummary(association, docParam);

                doc.AddParameter(docParam);
            }

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

            this.matchedAssociations.Add(association.Name, doc);

            if (type == null)
            {
                return;
            }

            type.AddMethod(doc);
        }
Exemplo n.º 3
0
        public void Add( List<Namespace> namespaces, DocumentedMethod association )
        {
            Namespace ns = null;
            DeclaredType type = null;
            try
            {
                if( association.Method == null ) return;

                ns = FindNamespace( association, namespaces );
                type = FindType( ns, association );

                var methodReturnType = DeclaredType.Unresolved(
                    Identifier.FromType( association.Method.ReturnType ),
                    association.Method.ReturnType,
                    Namespace.Unresolved( Identifier.FromNamespace( association.Method.ReturnType.Namespace ) ) );
                var doc = Method.Unresolved(
                    Identifier.FromMethod( association.Method, association.TargetType ),
                    type, association.Method, methodReturnType );

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

                foreach( var parameter in association.Method.GetParameters() )
                {
                    var reference = DeclaredType.Unresolved(
                        Identifier.FromType( parameter.ParameterType ),
                        parameter.ParameterType,
                        Namespace.Unresolved( Identifier.FromNamespace( parameter.ParameterType.Namespace ) ) );
                    var docParam = new MethodParameter( parameter.Name, 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 );
            }
            catch( IOException ex )
            {
                var doc = Method.Unresolved(
                    Identifier.FromMethod( association.Method, association.TargetType ),
                    type, association.Method, new NullReference() );
                type.AddMethod( doc );
            }
        }
Exemplo n.º 4
0
        private void ParseMethod(List<IDocumentationMember> members, XmlNode node)
        {
            string name = node.Attributes["name"].Value.Substring(2);
            Identifier member = Identifier.FromString(node.Attributes["name"].Value);
            string methodName = GetMethodName(name);
            int index = members.FindIndex(x => x.Name == member);

            if (index == -1) return; // TODO: Privates
            if (methodName == "#ctor") return; // TODO: Fix constructors

            for (int i = 0; i < members.Count; i++)
            {
                var methodMember = members[i] as UndocumentedMethod;

                if (methodMember != null && methodMember.Match(member))
                    members[i] = new DocumentedMethod(member, node, methodMember.Method, methodMember.TargetType);
            }
        }
Exemplo n.º 5
0
        private void AddMethod(List<Namespace> namespaces, List<IReferencable> references, DocumentedMethod association)
        {
            if (association.Method == null) return;

            NamespaceIdentifier namespaceName = Identifier.FromNamespace(association.TargetType.Namespace);
            TypeIdentifier typeName = Identifier.FromType(association.TargetType);
            Namespace @namespace = namespaces.Find(x => x.IsIdentifiedBy(namespaceName));

            if (@namespace == null)
            {
                AddNamespace(namespaces, new DocumentedType(association.Name.CloneAsNamespace(), null, association.TargetType));
                @namespace = namespaces.Find(x => x.IsIdentifiedBy(namespaceName));
            }

            DeclaredType type = @namespace.Types.FirstOrDefault(x => x.IsIdentifiedBy(typeName));

            if (type == null)
            {
                AddType(namespaces, references,
                        new DocumentedType(association.Name.CloneAsType(), null, association.TargetType));
                type = @namespace.Types.FirstOrDefault(x => x.IsIdentifiedBy(typeName));
            }

            DeclaredType methodReturnType = DeclaredType.Unresolved(
                Identifier.FromType(association.Method.ReturnType),
                association.Method.ReturnType,
                Namespace.Unresolved(Identifier.FromNamespace(association.Method.ReturnType.Namespace)));
            Method doc = Method.Unresolved(Identifier.FromMethod(association.Method, association.TargetType),
                                           association.Method, methodReturnType);

            references.Add(methodReturnType);

            if (association.Xml != null)
            {
                XmlNode summaryNode = association.Xml.SelectSingleNode("summary");

                if (summaryNode != null)
                    doc.Summary = commentContentParser.Parse(summaryNode);

                GetReferencesFromComment(references, doc.Summary);
            }

            foreach (var parameter in association.Method.GetParameters())
            {
                var reference = DeclaredType.Unresolved(
                    Identifier.FromType(parameter.ParameterType),
                    parameter.ParameterType,
                    Namespace.Unresolved(Identifier.FromNamespace(parameter.ParameterType.Namespace)));
                var docParam = new MethodParameter(parameter.Name, reference);

                references.Add(reference);

                if (association.Xml != null)
                {
                    XmlNode paramNode = association.Xml.SelectSingleNode("param[@name='" + parameter.Name + "']");

                    if (paramNode != null)
                        docParam.Summary = commentContentParser.Parse(paramNode);

                    GetReferencesFromComment(references, docParam.Summary);
                }

                doc.AddParameter(docParam);
            }

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

            references.Add(doc);
            matchedAssociations.Add(association.Name, doc);
            type.AddMethod(doc);
        }