コード例 #1
0
 /// <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;
 }
コード例 #2
0
        internal void Load(XElement xEpigraph)
        {
            epigraphData.Clear();
            if (xEpigraph == null)
            {
                throw new ArgumentNullException("xEpigraph");
            }

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

            IEnumerable<XElement> xItems = xEpigraph.Elements();
            textAuthors.Clear();
            foreach (var element in xItems)
            {
                switch (element.Name.LocalName)
                {
                    case ParagraphItem.Fb2ParagraphElementName:
                        ParagraphItem paragraph = new ParagraphItem();
                        try
                        {
                            paragraph.Load(element);
                            epigraphData.Add(paragraph);
                        }
                        catch (Exception ex)
                        {
                            Debug.Fail(string.Format("Failed to load paragraph: {0}.", ex.Message));
                        }
                        break;
                    case PoemItem.Fb2PoemElementName:
                        PoemItem poem = new PoemItem();
                        try
                        {
                            poem.Load(element);
                            epigraphData.Add(poem);
                        }
                        catch (Exception ex)
                        {
                            Debug.Fail(string.Format("Failed to load poem: {0}.", ex.Message));
                        }
                        break;
                    case CiteItem.Fb2CiteElementName:
                        CiteItem cite = new CiteItem();
                        try
                        {
                            cite.Load(element);
                            epigraphData.Add(cite);
                        }
                        catch (Exception ex)
                        {
                            Debug.Fail(string.Format("Failed to load citation: {0}.", ex.Message));
                        }
                        break;
                    case EmptyLineItem.Fb2EmptyLineElementName:
                        EmptyLineItem emptyLine = new EmptyLineItem();
                        try
                        {
                            epigraphData.Add(emptyLine);
                        }
                        catch (Exception ex)
                        {
                            Debug.Fail(string.Format("Failed to load empty line: {0}.", ex.Message));
                        }
                        break;
                    case TextAuthorItem.Fb2TextAuthorElementName:
                        TextAuthorItem author = new TextAuthorItem();
                        //SimpleText author = new SimpleText();
                        try
                        {
                            author.Load(element);
                            textAuthors.Add(author);
                        }
                        catch (Exception ex)
                        {
                            Debug.Fail(string.Format("Failed to load text author: {0}.", ex.Message));
                        }
                        break;
                    default:
                        Debug.Fail(string.Format("EpigraphItem:Load - invalid element <{0}> encountered in title ."), element.Name.LocalName);
                        break;
                }
            }

            XAttribute xID = xEpigraph.Attribute("id");
            if ((xID != null) &&(xID.Value != null))
            {
                ID = xID.Value;
            }
        }
コード例 #3
0
ファイル: CiteItem.cs プロジェクト: padarits/fb2librarynet
        internal void Load(XElement xCite)
        {
            citeData.Clear();
            if (xCite == null)
            {
                throw new ArgumentNullException("xCite");
            }

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

            textAuthors.Clear();
            IEnumerable <XElement> xItems = xCite.Elements();

            foreach (var element in xItems)
            {
                switch (element.Name.LocalName)
                {
                case ParagraphItem.Fb2ParagraphElementName:
                    ParagraphItem paragraph = new ParagraphItem();
                    try
                    {
                        paragraph.Load(element);
                        citeData.Add(paragraph);
                    }
                    catch (Exception)
                    {
                    }
                    break;

                case PoemItem.Fb2PoemElementName:
                    PoemItem poem = new PoemItem();
                    try
                    {
                        poem.Load(element);
                        citeData.Add(poem);
                    }
                    catch (Exception)
                    {
                    }
                    break;

                case EmptyLineItem.Fb2EmptyLineElementName:
                    EmptyLineItem emptyLine = new EmptyLineItem();
                    try
                    {
                        citeData.Add(emptyLine);
                    }
                    catch (Exception)
                    {
                    }
                    break;

                case SubTitleItem.Fb2SubtitleElementName:
                    SubTitleItem subtitle = new SubTitleItem();
                    try
                    {
                        subtitle.Load(element);
                        citeData.Add(subtitle);
                    }
                    catch (Exception)
                    {
                    }
                    break;

                case TableItem.Fb2TableElementName:
                    TableItem table = new TableItem();
                    try
                    {
                        table.Load(element);
                        citeData.Add(table);
                    }
                    catch (Exception)
                    {
                    }
                    break;

                case TextAuthorItem.Fb2TextAuthorElementName:
                    //ParagraphItem author = new ParagraphItem();
                    TextAuthorItem author = new TextAuthorItem();
                    try
                    {
                        author.Load(element);
                        textAuthors.Add(author);
                    }
                    catch (Exception)
                    {
                    }
                    break;

                default:
                    Debug.Fail(string.Format("CiteItem:Load - invalid element <{0}> encountered in title ."), element.Name.LocalName);
                    break;
                }
            }

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

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

            ID = null;
            XAttribute xID = xCite.Attribute("id");

            if ((xID != null) && (xID.Value != null))
            {
                ID = xID.Value;
            }
        }
コード例 #4
0
        internal void Load(XElement xEpigraph)
        {
            epigraphData.Clear();
            if (xEpigraph == null)
            {
                throw new ArgumentNullException("xEpigraph");
            }


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

            IEnumerable <XElement> xItems = xEpigraph.Elements();

            textAuthors.Clear();
            foreach (var element in xItems)
            {
                switch (element.Name.LocalName)
                {
                case ParagraphItem.Fb2ParagraphElementName:
                    ParagraphItem paragraph = new ParagraphItem();
                    try
                    {
                        paragraph.Load(element);
                        epigraphData.Add(paragraph);
                    }
                    catch (Exception ex)
                    {
                        Debug.Fail(string.Format("Failed to load paragraph: {0}.", ex.Message));
                    }
                    break;

                case PoemItem.Fb2PoemElementName:
                    PoemItem poem = new PoemItem();
                    try
                    {
                        poem.Load(element);
                        epigraphData.Add(poem);
                    }
                    catch (Exception ex)
                    {
                        Debug.Fail(string.Format("Failed to load poem: {0}.", ex.Message));
                    }
                    break;

                case CiteItem.Fb2CiteElementName:
                    CiteItem cite = new CiteItem();
                    try
                    {
                        cite.Load(element);
                        epigraphData.Add(cite);
                    }
                    catch (Exception ex)
                    {
                        Debug.Fail(string.Format("Failed to load citation: {0}.", ex.Message));
                    }
                    break;

                case EmptyLineItem.Fb2EmptyLineElementName:
                    EmptyLineItem emptyLine = new EmptyLineItem();
                    try
                    {
                        epigraphData.Add(emptyLine);
                    }
                    catch (Exception ex)
                    {
                        Debug.Fail(string.Format("Failed to load empty line: {0}.", ex.Message));
                    }
                    break;

                case TextAuthorItem.Fb2TextAuthorElementName:
                    TextAuthorItem author = new TextAuthorItem();
                    //SimpleText author = new SimpleText();
                    try
                    {
                        author.Load(element);
                        textAuthors.Add(author);
                    }
                    catch (Exception ex)
                    {
                        Debug.Fail(string.Format("Failed to load text author: {0}.", ex.Message));
                    }
                    break;

                default:
                    Debug.Fail(string.Format("EpigraphItem:Load - invalid element <{0}> encountered in title ."), element.Name.LocalName);
                    break;
                }
            }

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

            if ((xID != null) && (xID.Value != null))
            {
                ID = xID.Value;
            }
        }
コード例 #5
0
ファイル: CiteItem.cs プロジェクト: rajeshwarn/fb2converters
        internal void Load(XElement xCite)
        {
            citeData.Clear();
            if (xCite == null)
            {
                throw new ArgumentNullException("xCite");
            }

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

            textAuthors.Clear();
            IEnumerable<XElement> xItems = xCite.Elements();
            foreach (var element in xItems)
            {
                switch (element.Name.LocalName)
                {
                    case ParagraphItem.Fb2ParagraphElementName:
                        ParagraphItem paragraph = new ParagraphItem();
                        try
                        {
                            paragraph.Load(element);
                            citeData.Add(paragraph);
                        }
                        catch (Exception)
                        {
                        }
                        break;
                    case PoemItem.Fb2PoemElementName:
                        PoemItem poem = new PoemItem();
                        try
                        {
                            poem.Load(element);
                            citeData.Add(poem);
                        }
                        catch (Exception)
                        {
                        }
                        break;
                    case EmptyLineItem.Fb2EmptyLineElementName:
                        EmptyLineItem emptyLine = new EmptyLineItem();
                        try
                        {
                            citeData.Add(emptyLine);
                        }
                        catch (Exception)
                        {
                        }
                        break;
                    case SubTitleItem.Fb2SubtitleElementName:
                        SubTitleItem subtitle = new SubTitleItem();
                        try
                        {
                            subtitle.Load(element);
                            citeData.Add(subtitle);
                        }
                        catch (Exception)
                        {
                        }
                        break;
                    case TableItem.Fb2TableElementName:
                        TableItem table = new TableItem();
                        try
                        {
                            table.Load(element);
                            citeData.Add(table);

                        }
                        catch (Exception)
                        {
                        }
                        break;
                    case TextAuthorItem.Fb2TextAuthorElementName:
                        //ParagraphItem author = new ParagraphItem();
                        TextAuthorItem author = new TextAuthorItem();
                        try
                        {
                            author.Load(element);
                            textAuthors.Add(author);
                        }
                        catch (Exception)
                        {
                        }
                        break;
                    default:
                        Debug.Fail(string.Format("CiteItem:Load - invalid element <{0}> encountered in title ."), element.Name.LocalName);
                        break;
                }
            }

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

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