/// <summary>
        /// Converts "v" (poem) sub-element
        /// </summary>
        /// <returns>XHTML formatted representation</returns>
        public IHTMLItem Convert(VPoemParagraph paragraphItem,VElementConverterParamsV2 vElementConverterParams)
        {
            if (paragraphItem == null)
            {
                throw new ArgumentNullException("paragraphItem");
            }
            var paragraphConverter = new ParagraphConverterV2();
            var item = paragraphConverter.Convert(paragraphItem,
                new ParagraphConverterParamsV2
                {
                    ResultType =
                        ParagraphConvTargetEnumV2.Paragraph,
                    Settings = vElementConverterParams.Settings,
                    StartSection = false,
                });

            SetClassType(item, ElementStylesV2.VElement);

            //item.ID.Value = Settings.ReferencesManager.AddIdUsed(paragraphItem.ID, item);

            return item;
        }
Example #2
0
        internal void Load(XElement xStanza)
        {
            if (xStanza == null)
            {
                throw new ArgumentNullException(nameof(xStanza));
            }

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

            Title = null;
            XElement xTitle = xStanza.Element(xStanza.Name.Namespace + TitleItem.Fb2TitleElementName);

            if (xTitle != null)
            {
                Title = new TitleItem();
                try
                {
                    Title.Load(xTitle);
                }
                catch (Exception)
                {
                    // ignored
                }
            }

            SubTitle = null;
            XElement xSubtitle = xStanza.Element(xStanza.Name.Namespace + SubTitleItem.Fb2SubtitleElementName);

            if (xSubtitle != null)
            {
                SubTitle = new SubTitleItem();
                try
                {
                    SubTitle.Load(xSubtitle);
                }
                catch (Exception)
                {
                    // ignored
                }
            }

            _lines.Clear();
            IEnumerable <XElement> xLines = xStanza.Elements(xStanza.Name.Namespace + VPoemParagraph.Fb2VParagraphItemName);

            foreach (var xLine in xLines)
            {
                VPoemParagraph vline = new VPoemParagraph();
                try
                {
                    vline.Load(xLine);
                    _lines.Add(vline);
                }
                catch (Exception)
                {
                    // ignored
                }
            }

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

            if (xLang != null && xLang.Value != null)
            {
                Lang = xLang.Value;
            }
        }
Example #3
0
        internal void Load(XElement xStanza)
        {
            if (xStanza == null)
            {
                throw new ArgumentNullException("xStanza");
            }

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

            Title = null;
            XElement xTitle = xStanza.Element(xStanza.Name.Namespace + TitleItem.Fb2TitleElementName);
            if (xTitle != null)
            {
                Title = new TitleItem();
                try
                {
                    Title.Load(xTitle);
                }
                catch (Exception)
                {
                }
            }

            SubTitle = null;
            XElement xSubtitle = xStanza.Element(xStanza.Name.Namespace + SubTitleItem.Fb2SubtitleElementName);
            if (xSubtitle != null)
            {
                SubTitle = new SubTitleItem();
                try
                {
                    SubTitle.Load(xSubtitle);
                }
                catch (Exception)
                {
                }
            }

            lines.Clear();
            IEnumerable<XElement> xLines = xStanza.Elements(xStanza.Name.Namespace + VPoemParagraph.Fb2VParagraphItemName);
            foreach (var xLine in xLines)
            {
                VPoemParagraph vline = new VPoemParagraph();
                try
                {
                    vline.Load(xLine);
                    lines.Add(vline);
                }
                catch (Exception)
                {
                    continue;
                }
            }

            Lang = null;
            XAttribute xLang = xStanza.Attribute(XNamespace.Xml + "lang");
            if ((xLang != null) && (xLang.Value != null))
            {
                Lang = xLang.Value;
            }
        }