Ejemplo n.º 1
0
        internal void Load(XElement xRow)
        {
            if (xRow == null)
            {
                throw new ArgumentNullException("xRow");
            }

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

            IEnumerable <XElement> xCells = xRow.Elements();

            foreach (var cell in xCells)
            {
                switch (cell.Name.LocalName)
                {
                case TableHeadingItem.Fb2TableHeadingElementName:
                    TableHeadingItem heading = new TableHeadingItem();
                    try
                    {
                        heading.Load(cell);
                        cells.Add(heading);
                    }
                    catch (Exception)
                    {
                    }
                    break;

                case TableCellItem.Fb2TableCellElementName:
                    TableCellItem tableCell = new TableCellItem();
                    try
                    {
                        tableCell.Load(cell);
                        cells.Add(tableCell);
                    }
                    catch (Exception)
                    {
                    }
                    break;

                default:
                    Debug.Fail(string.Format("TableRowItem.Load - Unknown cell type {0}"), cell.Name.LocalName);
                    break;
                }
            }


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

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


            Style = null;
            XAttribute xStyle = xRow.Attribute("style");

            if ((xStyle != null) && (xStyle.Value != null))
            {
                Style = xStyle.Value;
            }

            Align = null;
            XAttribute xAlign = xRow.Attribute("align");

            if ((xAlign != null) && (xAlign.Value != null))
            {
                Align = xAlign.Value;
            }
        }
Ejemplo n.º 2
0
        internal void Load(XElement xRow)
        {
            if (xRow == null)
            {
                throw new ArgumentNullException("xRow");
            }

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

            IEnumerable<XElement> xCells = xRow.Elements();
            foreach (var cell in xCells)
            {
                switch (cell.Name.LocalName)
                {
                    case TableHeadingItem.Fb2TableHeadingElementName:
                        TableHeadingItem heading = new TableHeadingItem();
                        try
                        {
                            heading.Load(cell);
                            cells.Add(heading);

                        }
                        catch (Exception)
                        {

                        }
                        break;
                    case TableCellItem.Fb2TableCellElementName:
                        TableCellItem tableCell = new TableCellItem();
                        try
                        {
                            tableCell.Load(cell);
                            cells.Add(tableCell);
                        }
                        catch (Exception)
                        {

                        }
                        break;
                    default:
                        Debug.WriteLine(string.Format("TableRowItem.Load - Unknown cell type {0}"), cell.Name.LocalName);
                        break;
                }
            }


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


            Style = null;
            XAttribute xStyle = xRow.Attribute("style");
            if ((xStyle != null) && (xStyle.Value != null))
            {
                Style = xStyle.Value;
            }

            Align = null;
            XAttribute xAlign = xRow.Attribute("align");
            if ((xAlign != null) && (xAlign.Value != null))
            {
                Align = xAlign.Value;
            }
        }