Exemple #1
0
        internal void AddAt(int index, DataColumn column)
        {
            if (column != null && column.ColumnMapping == MappingType.SimpleContent)
            {
                if (_table.XmlText != null && _table.XmlText != column)
                {
                    throw ExceptionBuilder.CannotAddColumn3();
                }

                if (_table.ElementColumnCount > 0)
                {
                    throw ExceptionBuilder.CannotAddColumn4(column.ColumnName);
                }

                OnCollectionChanging(new CollectionChangeEventArgs(CollectionChangeAction.Add, column));
                BaseAdd(column);
                if (index != -1)
                {
                    ArrayAdd(index, column);
                }
                else
                {
                    ArrayAdd(column);
                }

                _table.XmlText = column;
            }
            else
            {
                OnCollectionChanging(new CollectionChangeEventArgs(CollectionChangeAction.Add, column));
                BaseAdd(column);
                if (index != -1)
                {
                    ArrayAdd(index, column);
                }
                else
                {
                    ArrayAdd(column);
                }

                // if the column is an element increase the internal dataTable counter
                if (column.ColumnMapping == MappingType.Element)
                {
                    _table.ElementColumnCount++;
                }
            }
            if (!_table.fInitInProgress && column != null && column.Computed)
            {
                column.CopyExpressionFrom(column);
            }
            OnCollectionChanged(new CollectionChangeEventArgs(CollectionChangeAction.Add, column));
        }
 internal void AddAt(int index, DataColumn column)
 {
     if ((column != null) && (column.ColumnMapping == MappingType.SimpleContent))
     {
         if ((this.table.XmlText != null) && (this.table.XmlText != column))
         {
             throw ExceptionBuilder.CannotAddColumn3();
         }
         if (this.table.ElementColumnCount > 0)
         {
             throw ExceptionBuilder.CannotAddColumn4(column.ColumnName);
         }
         this.OnCollectionChanging(new CollectionChangeEventArgs(CollectionChangeAction.Add, column));
         this.BaseAdd(column);
         if (index != -1)
         {
             this.ArrayAdd(index, column);
         }
         else
         {
             this.ArrayAdd(column);
         }
         this.table.XmlText = column;
     }
     else
     {
         this.OnCollectionChanging(new CollectionChangeEventArgs(CollectionChangeAction.Add, column));
         this.BaseAdd(column);
         if (index != -1)
         {
             this.ArrayAdd(index, column);
         }
         else
         {
             this.ArrayAdd(column);
         }
         if (column.ColumnMapping == MappingType.Element)
         {
             this.table.ElementColumnCount++;
         }
     }
     if ((!this.table.fInitInProgress && (column != null)) && column.Computed)
     {
         column.Expression = column.Expression;
     }
     this.OnCollectionChanged(new CollectionChangeEventArgs(CollectionChangeAction.Add, column));
 }