コード例 #1
0
        public void ReadFromXmlNode(IXmlCodeReader reader, XmlNode node)
        {
            TableName = XmlUtil.GetNameAttribute(node);
            XmlNodeList ns = node.SelectNodes(string.Format(CultureInfo.InvariantCulture,
                                                            "{0}/{1}", XML_Columns, WebPageDataSet.XML_Item));

            Columns = new WebDataColumn[ns.Count];
            for (int i = 0; i < ns.Count; i++)
            {
                Columns[i] = new WebDataColumn();
                Columns[i].ReadFromXmlNode(ns[i]);
            }
            Rows = new Dictionary <string, WebPageDataRow[]>();
            XmlNodeList ndrcs = node.SelectNodes(string.Format(CultureInfo.InvariantCulture,
                                                               "{0}/{1}", XML_Rows, XML_RowsC));

            foreach (XmlNode ndc in ndrcs)
            {
                string           culture = XmlUtil.GetAttribute(ndc, XMLATTR_culture);
                XmlNodeList      nrs     = ndc.SelectNodes(WebPageDataSet.XML_Item);
                WebPageDataRow[] rs      = new WebPageDataRow[nrs.Count];
                for (int i = 0; i < nrs.Count; i++)
                {
                    rs[i] = new WebPageDataRow();
                    rs[i].ReadFromXmlNode(reader, nrs[i]);
                }
                Rows.Add(culture, rs);
            }
        }
コード例 #2
0
 public PropertyDescriptorRowValue(WebPageDataRow row, int col, Type valueType, string name, Attribute[] attrs)
     : base(name, attrs)
 {
     _row      = row;
     _idx      = col;
     _dataType = valueType;
 }
コード例 #3
0
        public WebDataTable[] ChildTables; //an array of JsonDataTable. Get relations from JsonDataTable identified by table name
        public WebPageDataRow Clone()
        {
            WebPageDataRow r = new WebPageDataRow();

            if (ChildTables != null)
            {
                r.ChildTables = new WebDataTable[ChildTables.Length];
                for (int i = 0; i < ChildTables.Length; i++)
                {
                    r.ChildTables[i] = ChildTables[i];
                }
            }
            if (ItemArray != null)
            {
                r.ItemArray = new object[ItemArray.Length];
                for (int i = 0; i < ItemArray.Length; i++)
                {
                    ICloneable ic = ItemArray[i] as ICloneable;
                    if (ic != null)
                    {
                        r.ItemArray[i] = ic.Clone();
                    }
                    else
                    {
                        r.ItemArray[i] = ItemArray[i];
                    }
                }
            }
            return(r);
        }
コード例 #4
0
        public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
        {
            WebPageDataRow[] rows = GetCurrentRows();
            if (rows == null || rows.Length == 0)
            {
                rows    = new WebPageDataRow[1];
                rows[0] = new WebPageDataRow();
                if (this.Rows == null)
                {
                    this.Rows = new Dictionary <string, WebPageDataRow[]>();
                }
                if (CurrentCulture == null)
                {
                    CurrentCulture = string.Empty;
                }
                if (this.Rows.ContainsKey(CurrentCulture))
                {
                    this.Rows[CurrentCulture] = rows;
                }
                else
                {
                    this.Rows.Add(CurrentCulture, rows);
                }
            }
            WebPageDataRow r = rows[0];

            if (r == null)
            {
                r       = new WebPageDataRow();
                rows[0] = r;
            }

            if (Columns == null)
            {
                Columns = new WebDataColumn[] { };
            }
            if (r.ItemArray == null)
            {
                r.ItemArray = new object[Columns.Length];
            }
            else
            {
                if (r.ItemArray.Length < Columns.Length)
                {
                    object[] vs = new object[Columns.Length];
                    for (int i = 0; i < r.ItemArray.Length; i++)
                    {
                        vs[i] = r.ItemArray[i];
                    }
                    r.ItemArray = vs;
                }
            }
            PropertyDescriptor[] ps = new PropertyDescriptor[Columns.Length];
            for (int i = 0; i < Columns.Length; i++)
            {
                ps[i] = new PropertyDescriptorRowValue(r, i, Columns[i].SystemType, Columns[i].ColumnName, attributes);
            }
            return(new PropertyDescriptorCollection(ps));
        }
コード例 #5
0
 public void FinishEdit()
 {
     Rows = new Dictionary <string, WebPageDataRow[]>();
     if (_dataTables != null)
     {
         foreach (KeyValuePair <string, DataTable> kv in _dataTables)
         {
             WebPageDataRow[] rs = new WebPageDataRow[kv.Value.Rows.Count];
             for (int i = 0; i < kv.Value.Rows.Count; i++)
             {
                 rs[i]           = new WebPageDataRow();
                 rs[i].ItemArray = kv.Value.Rows[i].ItemArray;
             }
             Rows.Add(kv.Key, rs);
         }
     }
 }
コード例 #6
0
        //
        #region ICloneable Members

        public virtual WebDataTable Clone(WebPageDataSet dataset)
        {
            WebDataTable tbl = (WebDataTable)Activator.CreateInstance(this.GetType(), dataset);

            tbl.TableName  = TableName;
            tbl.PrimaryKey = PrimaryKey;
            if (Columns != null)
            {
                tbl.Columns = new WebDataColumn[Columns.Length];
                for (int i = 0; i < Columns.Length; i++)
                {
                    tbl.Columns[i] = Columns[i].Clone();
                }
            }
            if (DataRelations != null)
            {
                tbl.DataRelations = new WebDataRelation[DataRelations.Length];
                for (int i = 0; i < DataRelations.Length; i++)
                {
                    tbl.DataRelations[i] = DataRelations[i].Clone();
                }
            }
            if (Rows != null)
            {
                tbl.Rows = new Dictionary <string, WebPageDataRow[]>();
                foreach (KeyValuePair <string, WebPageDataRow[]> kv in Rows)
                {
                    WebPageDataRow[] dr;
                    if (kv.Value == null)
                    {
                        dr = new WebPageDataRow[] { };
                    }
                    else
                    {
                        dr = new WebPageDataRow[kv.Value.Length];
                        for (int i = 0; i < kv.Value.Length; i++)
                        {
                            dr[i] = kv.Value[i].Clone();
                        }
                    }
                    tbl.Rows.Add(kv.Key, dr);
                }
            }
            return(tbl);
        }
コード例 #7
0
 public void UpdateColumns(WebDataColumn[] tableColumns)
 {
     if (tableColumns == null)
     {
         tableColumns = new WebDataColumn[] { };
     }
     if (Columns == null || Columns.Length == 0)
     {
         Columns = tableColumns;
     }
     else
     {
         bool changed = true;
         if (Columns.Length == tableColumns.Length)
         {
             changed = false;
             for (int i = 0; i < Columns.Length; i++)
             {
                 if (string.Compare(Columns[i].ColumnName, tableColumns[i].ColumnName, StringComparison.OrdinalIgnoreCase) != 0)
                 {
                     changed = true;
                 }
             }
         }
         if (changed)
         {
             bool  hasData = false;
             int[] map     = new int[tableColumns.Length];
             for (int i = 0; i < tableColumns.Length; i++)
             {
                 map[i] = -1;
                 for (int j = 0; j < Columns.Length; j++)
                 {
                     if (string.Compare(tableColumns[i].ColumnName, Columns[j].ColumnName, StringComparison.OrdinalIgnoreCase) == 0)
                     {
                         map[i]  = j;
                         hasData = true;
                         break;
                     }
                 }
             }
             if (hasData)
             {
                 if (Rows != null)
                 {
                     Dictionary <string, WebPageDataRow[]> newRows = new Dictionary <string, WebPageDataRow[]>();
                     foreach (KeyValuePair <string, WebPageDataRow[]> kv in Rows)
                     {
                         WebPageDataRow[] rs;
                         if (kv.Value == null)
                         {
                             rs = new WebPageDataRow[] { };
                         }
                         else
                         {
                             rs = new WebPageDataRow[kv.Value.Length];
                             for (int i = 0; i < rs.Length; i++)
                             {
                                 rs[i]           = new WebPageDataRow();
                                 rs[i].ItemArray = new object[tableColumns.Length];
                                 for (int j = 0; j < tableColumns.Length; j++)
                                 {
                                     if (map[j] < 0)
                                     {
                                         rs[i].ItemArray[j] = null;
                                     }
                                     else
                                     {
                                         rs[i].ItemArray[j] = kv.Value[i].ItemArray[map[j]];
                                     }
                                 }
                             }
                         }
                         newRows.Add(kv.Key, rs);
                     }
                     Rows = newRows;
                 }
             }
             else
             {
                 Rows = null;
             }
             Columns = tableColumns;
         }
     }
 }