コード例 #1
0
        private static void WriteQualifiedListItem(this MamlWriter writer,
                                                   Context context, ListItem item, Topic topic)
        {
            string parentName = GetSchemaObjectName(context, topic.SchemaObject);

            if (String.IsNullOrEmpty(parentName))
            {
                writer.WriteArtItemWithTopicLink(item.ArtItem, topic);
            }
            else
            {
                writer.WriteArtItemWithTopicLink(item.ArtItem, topic,
                                                 parentName + "\\" + topic.LinkTitle);
            }
        }
コード例 #2
0
 protected override void Visit(XmlSchemaSimpleType type)
 {
     if (type.QualifiedName.IsEmpty)
     {
         Traverse(type.Content);
     }
     else
     {
         var topic = _context.TopicManager.GetTopic(type);
         if (topic != null)
         {
             _writer.WriteArtItemWithTopicLink(ArtItem.SimpleType, topic);
         }
         else
         {
             _writer.WriteArtItemWithText(ArtItem.SimpleType, type.QualifiedName.Name);
         }
     }
 }
コード例 #3
0
        private static void WriteImageWithTopicLink(this MamlWriter writer, TopicManager topicManager, ArtItem artItem, XmlSchemaType type)
        {
            var topic = topicManager.GetTopic(type);

            if (topic != null)
            {
                writer.WriteArtItemWithTopicLink(artItem, topic);
            }
            else
            {
                writer.WriteArtItemWithText(artItem, type.QualifiedName.Name);
            }
        }
コード例 #4
0
        private static void WriteElementLink(this MamlWriter writer,
                                             TopicManager topicManager, XmlSchemaElement element,
                                             bool isExtension, int index)
        {
            var artItem = element.RefName.IsEmpty && !isExtension
                            ? ArtItem.Element
                            : ArtItem.ElementRef;
            var topic = topicManager.GetTopic(element);

            if (topic != null)
            {
                writer.WriteArtItemWithTopicLink(artItem, topic, index);
            }
            else
            {
                writer.WriteArtItemWithText(artItem,
                                            element.QualifiedName.Name, index);
            }
        }
コード例 #5
0
        private static void WriteAttributeTopicLink(this MamlWriter writer,
                                                    TopicManager topicManager, XmlSchemaAttribute attribute,
                                                    bool isExtension, int indent)
        {
            var artItem = attribute.RefName.IsEmpty && !isExtension
                            ? ArtItem.Attribute
                            : ArtItem.AttributeRef;

            var topic = topicManager.GetTopic(attribute);

            if (topic != null)
            {
                writer.WriteArtItemWithTopicLink(artItem, topic, indent);
            }
            else
            {
                writer.WriteArtItemWithText(artItem,
                                            attribute.QualifiedName.Name, indent);
            }
        }
コード例 #6
0
        private static void WriteQualifiedList(this MamlWriter writer,
                                               Context context, MultiMap <string, ListItem> listMap)
        {
            int index = 0;

            IEnumerable <string> keys = listMap.Keys;

            foreach (string key in keys)
            {
                IList <ListItem> qualifiedItems = listMap[key];

                if (qualifiedItems.Count == 1)
                {
                    ListItem item = qualifiedItems[0];
                    // Write a separator...
                    if (index > 0)
                    {
                        writer.WriteStartElement("phrase"); //phrase
                        writer.WriteString(" |");
                        writer.WriteEndElement();           //phrase
                    }

                    writer.WriteArtItemWithTopicLink(item.ArtItem, item.Topic);

                    index++;
                }
                else
                {
                    MultiMap <string, ListItem> listMapNext = new MultiMap <string, ListItem>();

                    for (int i = 0; i < qualifiedItems.Count; i++)
                    {
                        ListItem item = qualifiedItems[i];

                        listMapNext.Add(GetQualifiedListItem(
                                            context, item, item.Topic), item);
                    }

                    IEnumerable <string> keysNext = listMapNext.Keys;
                    foreach (string keyNext in keysNext)
                    {
                        IList <ListItem> qualifiedItemsNext = listMapNext[keyNext];

                        if (qualifiedItemsNext.Count == 1)
                        {
                            ListItem itemNext = qualifiedItemsNext[0];
                            // Write a separator...
                            if (index > 0)
                            {
                                writer.WriteStartElement("phrase"); //phrase
                                writer.WriteString(" |");
                                writer.WriteEndElement();           //phrase
                            }

                            writer.WriteQualifiedListItem(context, itemNext, itemNext.Topic);

                            index++;
                        }
                        else
                        {
                            for (int i = 0; i < qualifiedItemsNext.Count; i++)
                            {
                                ListItem itemNext = qualifiedItemsNext[i];
                                // Write a separator...
                                if (index > 0)
                                {
                                    writer.WriteStartElement("phrase"); //phrase
                                    writer.WriteString(" |");
                                    writer.WriteEndElement();           //phrase
                                }

                                writer.WriteQualifiedListItem(context, itemNext,
                                                              itemNext.Topic, keyNext);

                                index++;
                            }
                        }
                    }

                    //for (int i = 0; i < qualifiedItems.Count; i++)
                    //{
                    //    ListItem item = qualifiedItems[i];
                    //    // Write a separator...
                    //    if (index > 0)
                    //    {
                    //        writer.WriteStartElement("phrase"); //phrase
                    //        writer.WriteString(" |");
                    //        writer.WriteEndElement();           //phrase
                    //    }

                    //    //writer.WriteArtItemWithTopicLink(item.ArtItem, item.Topic);
                    //    writer.WriteQualifiedListItem(context, item, item.Topic);

                    //    index++;
                    //}
                }
            }
        }
コード例 #7
0
        public static void WriteList(this MamlWriter writer,
                                     Context context, IList <ListItem> listItems)
        {
            int itemCount = listItems.Count;

            if (itemCount > 1)
            {
                writer.WriteStartElement("phrase"); //phrase
                writer.WriteString("|");
                writer.WriteEndElement();           //phrase
            }

            if (itemCount == 1)
            {
                ListItem item = listItems[0];
                writer.WriteArtItemWithTopicLink(item.ArtItem, item.Topic);
            }
            else if (itemCount == 2)
            {
                ListItem item1  = listItems[0];
                ListItem item2  = listItems[1];
                Topic    topic1 = item1.Topic;
                Topic    topic2 = item2.Topic;

                if (String.Equals(topic1.LinkTitle, topic2.LinkTitle,
                                  StringComparison.Ordinal))
                {
                    writer.WriteQualifiedListItem(context, item1, topic1);

                    writer.WriteStartElement("phrase"); //phrase
                    writer.WriteString(" |");
                    writer.WriteEndElement();           //phrase

                    writer.WriteQualifiedListItem(context, item2, topic2);
                }
                else
                {
                    writer.WriteArtItemWithTopicLink(item1.ArtItem, topic1);

                    writer.WriteStartElement("phrase"); //phrase
                    writer.WriteString(" |");
                    writer.WriteEndElement();           //phrase

                    writer.WriteArtItemWithTopicLink(item2.ArtItem, topic2);
                }
            }
            else
            {
                MultiMap <string, ListItem> listMap = new MultiMap <string, ListItem>();

                for (int i = 0; i < itemCount; i++)
                {
                    ListItem item = listItems[i];

                    listMap.Add(item.Topic.LinkTitle, item);
                }

                if (listMap.IsMultiValue)
                {
                    writer.WriteQualifiedList(context, listMap);
                }
                else
                {
                    for (int i = 0; i < itemCount; i++)
                    {
                        ListItem item = listItems[i];
                        // Write a separator...
                        if (i > 0)
                        {
                            writer.WriteStartElement("phrase"); //phrase
                            writer.WriteString(" |");
                            writer.WriteEndElement();           //phrase
                        }

                        writer.WriteArtItemWithTopicLink(item.ArtItem, item.Topic);
                    }
                }
            }
            if (itemCount > 1)
            {
                writer.WriteStartElement("phrase"); //phrase
                writer.WriteString(" |");
                writer.WriteEndElement();           //phrase
            }
        }