Ejemplo n.º 1
0
        private void AddTopic <T>(
            Func <T, string> id,
            Func <T, string> name,
            Func <T, string> title,
            Func <T, string> notes,
            Func <T, string> folder_name,
            Func <T, IEnumerable> diagrams   = null,
            Func <T, string> description     = null,
            Action <TopicConfig <T> > config = null)
        {
            var cfg = new ExportTopicConfig(
                x => id((T)x),
                x => name((T)x),
                x => title((T)x),
                x => notes((T)x),
                x => folder_name((T)x),
                x => (diagrams == null) ? new object[0] :  diagrams((T)x),
                x => description?.Invoke((T)x)
                );

            var c = new TopicConfig <T>(cfg);

            config(c);
            this.topics.Add(typeof(T), cfg);
        }
Ejemplo n.º 2
0
 public TopicConfig(ExportTopicConfig cfg)
 {
     this.cfg = cfg;
 }
Ejemplo n.º 3
0
        private void ExportObjectBody(object element, ExportTopicConfig topic_config, string path, XmlWriter tocWriter)
        {
            var file_name = Path.Combine(root_path, path + ".dita");

            if (file_name.Length > max_path_length)
            {
                MessageBox.Show($"Very long name {file_name}");
                return;
            }

            using (var writer = XmlWriter.Create(file_name, new XmlWriterSettings
            {
                Indent = true
            }))
            {
                writer.WriteStartDocument();

                writer.WriteDocType("topic", "-//OASIS//DTD DITA Topic//EN", "topic.dtd", null);

                writer.WriteStartElement("topic");
                writer.WriteAttributeString("id", topic_config.id_func(element));

                writer.WriteElementString("title", topic_config.title_func(element));

                if (topic_config.description_func != null)
                {
                    writer.WriteElementString("shortdesc", topic_config.description_func(element));
                }

                writer.WriteStartElement("body");

                writer.WriteStartElement("p");
                writer.WriteRaw(topic_config.notes_func(element));
                writer.WriteEndElement();//p

                foreach (Diagram diagram in topic_config.diagrams_func(element))
                {
                    writer.WriteStartElement("fig");
                    writer.WriteAttributeString("id", "eadiagram" + diagram.DiagramID);

                    writer.WriteElementString("title", diagram.Name);

                    writer.WriteStartElement("image");
                    writer.WriteAttributeString("placement", "break");
                    writer.WriteAttributeString("scalefit", "yes");
                    writer.WriteAttributeString("href", "images/" + ExportConfig.Translit(diagram.Name) + ".png");
                    writer.WriteEndElement(); //image

                    writer.WriteEndElement(); //fig
                }

                foreach (var body_config in topic_config.body)
                {
                    RenderBody(element, body_config, writer);
                }


                writer.WriteEndElement();//body


                writer.WriteEndElement();//topic
                writer.WriteEndDocument();
            }
        }