Exemplo n.º 1
0
        private void WriteSimpleMember(SimpleMemberReference member, DisplayOptions options, XmlWriter writer, Dictionary <IndexedTemplateTypeReference, TypeReference> dictionary)
        {
            MemberTarget target = targets[member.Id] as MemberTarget;

            if (target != null)
            {
                WriteMemberTarget(target, options, writer, dictionary);
            }
            else
            {
                TextReferenceUtilities.WriteSimpleMemberReference(member, options, writer, this);
            }
        }
        private static EnumerationTarget CreateEnumerationTarget(XPathNavigator api)
        {
            string typeId = (string)api.Evaluate(topicIdExpression);
            string file   = (string)api.Evaluate(topicFileExpression);

            // Create target
            List <MemberTarget> members      = new List <MemberTarget>();
            XPathNodeIterator   elementNodes = api.Select("elements/element");

            foreach (XPathNavigator elementNode in elementNodes)
            {
                string memberId = elementNode.GetAttribute("api", String.Empty);

                // Try to get name from attribute on element node
                string memberName = elementNode.GetAttribute("name", String.Empty);

                if (String.IsNullOrEmpty(memberName))
                {
                    // If we can't do that, try to get the name by searching the file for the <api> element of
                    // that member.
                    XPathNavigator memberApi = api.SelectSingleNode(String.Format(CultureInfo.InvariantCulture,
                                                                                  "following-sibling::api[@id='{0}']", memberId));

                    if (memberApi != null)
                    {
                        memberName = (string)memberApi.Evaluate(apiNameExpression);
                    }
                    else
                    {
                        // If all else fails, get the name by parsing the identifier
                        string arguments;
                        string type;

                        TextReferenceUtilities.DecomposeMemberIdentifier(memberId, out type, out memberName,
                                                                         out arguments);
                    }
                }

                MemberTarget member = new MemberTarget();

                member.Id             = memberId;                        // Get Id from element
                member.File           = file;                            // Get file from type file
                member.Name           = memberName;                      // Get name from element
                member.ContainingType = new SimpleTypeReference(typeId); // Get containing type from this type
                members.Add(member);
            }

            return(new EnumerationTarget(members));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Write out the target link information
        /// </summary>
        /// <param name="target">The target for which to write link information</param>
        /// <param name="options">The link display options</param>
        /// <param name="writer">The write to which the information is written</param>
        public void WriteTarget(Target target, DisplayOptions options, XmlWriter writer)
        {
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }

            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }

            NamespaceTarget space = target as NamespaceTarget;

            if (space != null)
            {
                WriteNamespaceTarget(space, writer);
                return;
            }

            TypeTarget type = target as TypeTarget;

            if (type != null)
            {
                WriteTypeTarget(type, options, writer);
                return;
            }

            MemberTarget member = target as MemberTarget;

            if (member != null)
            {
                WriteMemberTarget(member, options, writer);
                return;
            }

            if (target.Id.StartsWith("R:", StringComparison.OrdinalIgnoreCase))
            {
                WriteInvalid(new InvalidReference(target.Id), writer);
                return;
            }

            throw new InvalidOperationException("Unknown target type");
        }
        /// <summary>
        /// Create a member target
        /// </summary>
        /// <param name="api">The node from which to get the target information</param>
        /// <returns>The member target</returns>
        public static MemberTarget CreateMemberTarget(XPathNavigator api)
        {
            string subgroup = (string)api.Evaluate(apiSubgroupExpression);

            MemberTarget target;

            if (subgroup == "method")
            {
                target = CreateMethodTarget(api);
            }
            else
            if (subgroup == "property")
            {
                target = CreatePropertyTarget(api);
            }
            else
            if (subgroup == "constructor")
            {
                target = new ConstructorTarget(CreateParameterList(api));
            }
            else
            if (subgroup == "event")
            {
                target = CreateEventTarget(api);
            }
            else
            {
                target = new MemberTarget();
            }

            target.Name           = (string)api.Evaluate(apiNameExpression);
            target.ContainingType = CreateSimpleTypeReference(api.SelectSingleNode(apiContainingTypeExpression));
            target.OverloadId     = (string)api.Evaluate(apiOverloadIdExpression);

            return(target);
        }
Exemplo n.º 5
0
        private void WriteMemberTarget(MemberTarget target, DisplayOptions options, XmlWriter writer, Dictionary <IndexedTemplateTypeReference, TypeReference> dictionary)
        {
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }

            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }

            MethodTarget method = target as MethodTarget;

            if ((options & DisplayOptions.ShowContainer) > 0)
            {
                WriteType(target.ContainingType, options & ~DisplayOptions.ShowContainer, writer);

                if (method != null && method.IsConversionOperator)
                {
                    writer.WriteString(" ");
                }
                else
                {
                    WriteSeparator(writer);
                }
            }

            // special logic for writing methods
            if (method != null)
            {
                WriteMethod(method, options, writer, dictionary);
                return;
            }

            // special logic for writing properties
            PropertyTarget property = target as PropertyTarget;

            if (property != null)
            {
                WriteProperty(property, options, writer);
                return;
            }

            // special logic for writing constructors
            ConstructorTarget constructor = target as ConstructorTarget;

            if (constructor != null)
            {
                WriteConstructor(constructor, options, writer);
                return;
            }

            // special logic for writing events
            EventTarget trigger = target as EventTarget;

            if (trigger != null)
            {
                WriteEvent(trigger, writer);
                return;
            }

            // by default, just write name
            writer.WriteString(target.Name);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Write out a member target
 /// </summary>
 /// <param name="target">The member target information</param>
 /// <param name="options">The link display options</param>
 /// <param name="writer">The write to which the information is written</param>
 public void WriteMemberTarget(MemberTarget target, DisplayOptions options, XmlWriter writer)
 {
     WriteMemberTarget(target, options, writer, null);
 }
        /// <summary>
        /// Create a member target
        /// </summary>
        /// <param name="api">The node from which to get the target information</param>
        /// <returns>The member target</returns>
        public static MemberTarget CreateMemberTarget(XPathNavigator api)
        {
            string subgroup = (string)api.Evaluate(apiSubgroupExpression);

            MemberTarget target;

            if(subgroup == "method")
                target = CreateMethodTarget(api);
            else
                if(subgroup == "property")
                    target = CreatePropertyTarget(api);
                else
                    if(subgroup == "constructor")
                        target = new ConstructorTarget(CreateParameterList(api));
                    else
                        if(subgroup == "event")
                            target = CreateEventTarget(api);
                        else
                            target = new MemberTarget();

            target.Name = (string)api.Evaluate(apiNameExpression);
            target.ContainingType = CreateSimpleTypeReference(api.SelectSingleNode(apiContainingTypeExpression));
            target.OverloadId = (string)api.Evaluate(apiOverloadIdExpression);

            return target;
        }
        private static EnumerationTarget CreateEnumerationTarget(XPathNavigator api)
        {
            string typeId = (string)api.Evaluate(topicIdExpression);
            string file = (string)api.Evaluate(topicFileExpression);

            // Create target
            List<MemberTarget> members = new List<MemberTarget>();
            XPathNodeIterator elementNodes = api.Select("elements/element");

            foreach(XPathNavigator elementNode in elementNodes)
            {
                string memberId = elementNode.GetAttribute("api", String.Empty);

                // Try to get name from attribute on element node
                string memberName = elementNode.GetAttribute("name", String.Empty);

                if(String.IsNullOrEmpty(memberName))
                {
                    // If we can't do that, try to get the name by searching the file for the <api> element of
                    // that member.
                    XPathNavigator memberApi = api.SelectSingleNode(String.Format(CultureInfo.InvariantCulture,
                        "following-sibling::api[@id='{0}']", memberId));

                    if(memberApi != null)
                        memberName = (string)memberApi.Evaluate(apiNameExpression);
                    else
                    {
                        // If all else fails, get the name by parsing the identifier
                        string arguments;
                        string type;

                        TextReferenceUtilities.DecomposeMemberIdentifier(memberId, out type, out memberName,
                            out arguments);
                    }
                }

                MemberTarget member = new MemberTarget();

                member.Id = memberId;       // Get Id from element
                member.File = file;         // Get file from type file
                member.Name = memberName;   // Get name from element
                member.ContainingType = new SimpleTypeReference(typeId); // Get containing type from this type
                members.Add(member);
            }

            return new EnumerationTarget(members);
        }
Exemplo n.º 9
0
        private void WriteMemberTarget(MemberTarget target, DisplayOptions options, XmlWriter writer, Dictionary<IndexedTemplateTypeReference, TypeReference> dictionary)
        {
            if(target == null)
                throw new ArgumentNullException("target");

            if(writer == null)
                throw new ArgumentNullException("writer");

            MethodTarget method = target as MethodTarget;

            if((options & DisplayOptions.ShowContainer) > 0)
            {
                WriteType(target.ContainingType, options & ~DisplayOptions.ShowContainer, writer);

                if(method != null && method.IsConversionOperator)
                    writer.WriteString(" ");
                else
                    WriteSeparator(writer);
            }

            // special logic for writing methods
            if(method != null)
            {
                WriteMethod(method, options, writer, dictionary);
                return;
            }

            // special logic for writing properties
            PropertyTarget property = target as PropertyTarget;

            if(property != null)
            {
                WriteProperty(property, options, writer);
                return;
            }

            // special logic for writing constructors
            ConstructorTarget constructor = target as ConstructorTarget;

            if(constructor != null)
            {
                WriteConstructor(constructor, options, writer);
                return;
            }

            // special logic for writing events
            EventTarget trigger = target as EventTarget;

            if(trigger != null)
            {
                WriteEvent(trigger, writer);
                return;
            }

            // by default, just write name
            writer.WriteString(target.Name);
        }
Exemplo n.º 10
0
 /// <summary>
 /// Write out a member target
 /// </summary>
 /// <param name="target">The member target information</param>
 /// <param name="options">The link display options</param>
 /// <param name="writer">The write to which the information is written</param>
 public void WriteMemberTarget(MemberTarget target, DisplayOptions options, XmlWriter writer)
 {
     WriteMemberTarget(target, options, writer, null);
 }