/// <summary>
        /// Convert epigraph author FB2 element
        /// </summary>
        /// <param name="textAuthorItem">item to convert</param>
        /// <param name="epigraphAuthorConverterParams"></param>
        /// <returns>XHTML representation</returns>
        public IHTMLItem Convert(TextAuthorItem textAuthorItem, EpigraphAuthorConverterParamsV3 epigraphAuthorConverterParams)
        {
            if (textAuthorItem == null)
            {
                throw new ArgumentNullException("textAuthorItem");
            }
            var epigraphAuthor     = new Div(HTMLElementType.HTML5);
            var paragraphConverter = new ParagraphConverterV3();

            epigraphAuthor.Add(paragraphConverter.Convert(textAuthorItem,
                                                          new ParagraphConverterParamsV3 {
                ResultType = ParagraphConvTargetEnumV3.Paragraph, Settings = epigraphAuthorConverterParams.Settings, StartSection = false
            }));
            SetClassType(epigraphAuthor, ElementStylesV3.EpigraphAuthor);
            return(epigraphAuthor);
        }
Exemplo n.º 2
0
        internal void Load(XElement xPoem)
        {
            if (xPoem == null)
            {
                throw new ArgumentNullException("xPoem");
            }

            if (xPoem.Name.LocalName != Fb2PoemElementName)
            {
                throw new ArgumentException("Element of wrong type passed", "xPoem");
            }

            Title = null;
            Date = null;
            epigraphs.Clear();
            content.Clear();
            authors.Clear();

            IEnumerable<XElement> xElements = xPoem.Elements();
            foreach (var xElement in xElements)
            {
                if (xElement.Name == (XName)(xPoem.Name.Namespace + StanzaItem.Fb2StanzaElementName))
                {
                    StanzaItem stanza = new StanzaItem();
                    try
                    {
                        stanza.Load(xElement);
                        content.Add(stanza);
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                }
                else if (xElement.Name == (XName)(xPoem.Name.Namespace + SubTitleItem.Fb2SubtitleElementName))
                {
                    SubTitleItem subtitle = new SubTitleItem();
                    try
                    {
                        subtitle.Load(xElement);
                        content.Add(subtitle);
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                }
                else if (xElement.Name == (XName)(xPoem.Name.Namespace + TitleItem.Fb2TitleElementName) && Title == null) // only one title
                {
                        Title = new TitleItem();
                        Title.Load(xElement);
                }
                else if (xElement.Name == (XName)(xPoem.Name.Namespace + EpigraphItem.Fb2EpigraphElementName))
                {
                    EpigraphItem epigraphItem = new EpigraphItem();
                    try
                    {
                        epigraphItem.Load(xElement);
                        epigraphs.Add(epigraphItem);
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                }
                else if (xElement.Name == (XName)(xPoem.Name.Namespace + TextAuthorItem.Fb2TextAuthorElementName))
                {
                    TextAuthorItem author = new TextAuthorItem();
                    try
                    {
                        author.Load(xElement);
                        authors.Add(author);
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                }
                else if (xElement.Name == (XName)(xPoem.Name.Namespace + DateItem.Fb2DateElementName) && Date == null) // only one date
                {
                    Date = new DateItem();
                    try
                    {
                        Date.Load(xElement);
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                }
            }

            XAttribute xID = xPoem.Attribute("id");
            if ((xID != null) && (xID.Value != null))
            {
                ID = xID.Value;
            }

            Lang = null;
            XAttribute xLang = xPoem.Attribute(XNamespace.Xml + "lang");
            if ((xLang != null) && (xLang.Value != null))
            {
                Lang = xLang.Value;
            }
        }
Exemplo n.º 3
0
        internal void Load(XElement xPoem)
        {
            if (xPoem == null)
            {
                throw new ArgumentNullException("xPoem");
            }

            if (xPoem.Name.LocalName != Fb2PoemElementName)
            {
                throw new ArgumentException("Element of wrong type passed", "xPoem");
            }

            Title = null;
            Date  = null;
            epigraphs.Clear();
            content.Clear();
            authors.Clear();

            IEnumerable <XElement> xElements = xPoem.Elements();

            foreach (var xElement in xElements)
            {
                if (xElement.Name == (XName)(xPoem.Name.Namespace + StanzaItem.Fb2StanzaElementName))
                {
                    StanzaItem stanza = new StanzaItem();
                    try
                    {
                        stanza.Load(xElement);
                        content.Add(stanza);
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                }
                else if (xElement.Name == (XName)(xPoem.Name.Namespace + SubTitleItem.Fb2SubtitleElementName))
                {
                    SubTitleItem subtitle = new SubTitleItem();
                    try
                    {
                        subtitle.Load(xElement);
                        content.Add(subtitle);
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                }
                else if (xElement.Name == (XName)(xPoem.Name.Namespace + TitleItem.Fb2TitleElementName) && Title == null) // only one title
                {
                    Title = new TitleItem();
                    Title.Load(xElement);
                }
                else if (xElement.Name == (XName)(xPoem.Name.Namespace + EpigraphItem.Fb2EpigraphElementName))
                {
                    EpigraphItem epigraphItem = new EpigraphItem();
                    try
                    {
                        epigraphItem.Load(xElement);
                        epigraphs.Add(epigraphItem);
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                }
                else if (xElement.Name == (XName)(xPoem.Name.Namespace + TextAuthorItem.Fb2TextAuthorElementName))
                {
                    TextAuthorItem author = new TextAuthorItem();
                    try
                    {
                        author.Load(xElement);
                        authors.Add(author);
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                }
                else if (xElement.Name == (XName)(xPoem.Name.Namespace + DateItem.Fb2DateElementName) && Date == null) // only one date
                {
                    Date = new DateItem();
                    try
                    {
                        Date.Load(xElement);
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                }
            }

            XAttribute xID = xPoem.Attribute("id");

            if ((xID != null) && (xID.Value != null))
            {
                ID = xID.Value;
            }

            Lang = null;
            XAttribute xLang = xPoem.Attribute(XNamespace.Xml + "lang");

            if ((xLang != null) && (xLang.Value != null))
            {
                Lang = xLang.Value;
            }
        }