Ejemplo n.º 1
0
        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 = CreateConstructorTarget(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.overload = (string) api.Evaluate(apiOverloadIdExpression);

            return (target);
        }
Ejemplo n.º 2
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");

            if ((options & DisplayOptions.ShowContainer) > 0) {
                TypeReference type = target.Type;
                WriteType(type, options & ~DisplayOptions.ShowContainer, writer);
                MethodTarget methodTarget = target as MethodTarget;
                if (methodTarget != null) {
                    if (methodTarget.conversionOperator) { 
                        writer.WriteString(" ");
                    } else { 
                        WriteSeperator(writer); 
                    }
                } else {
                    WriteSeperator(writer);
                }
            }

            // special logic for writing methods
            MethodTarget method = target as MethodTarget;
            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, options, writer);
                return;
            }

            // by default, just write name
            writer.WriteString(target.Name);
        }
Ejemplo n.º 3
0
        private static EnumerationTarget CreateEnumerationTarget (XPathNavigator api, LinkType2 linkType) {

            EnumerationTarget enumeration = new EnumerationTarget();

            string typeId = (string) api.Evaluate(topicIdExpression);
            string file = (string) api.Evaluate(topicFileExpression);

            // Create tar
            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("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.type = linkType;
                member.name = memberName; // get name from element
                member.containingType = new SimpleTypeReference(typeId); // get containing type from this type
                members.Add(member);
            }

            enumeration.elements = members.ToArray();

            return (enumeration);
        }
Ejemplo n.º 4
0
 public void WriteMemberTarget (MemberTarget target, DisplayOptions options, XmlWriter writer) {
     WriteMemberTarget(target, options, writer, null);
 }