Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ InsertRow() [2/3]

void System.Data.DataTable.InsertRow ( DataRow row,
long proposedID )
inlinepackageinherited

Definition at line 2957 of file DataTable.cs.

2958 {
2959 long scopeId = DataCommonEventSource.Log.EnterScope("<ds.DataTable.InsertRow|INFO> {0}, row={1}", ObjectID, row._objectID);
2960 try
2961 {
2962 if (row.Table != this)
2963 {
2964 throw ExceptionBuilder.RowAlreadyInOtherCollection();
2965 }
2966 if (row.rowID != -1)
2967 {
2968 throw ExceptionBuilder.RowAlreadyInTheCollection();
2969 }
2970 if (row._oldRecord == -1 && row._newRecord == -1)
2971 {
2972 throw ExceptionBuilder.RowEmpty();
2973 }
2974 if (proposedID == -1)
2975 {
2977 }
2979 if (_nextRowID <= proposedID)
2980 {
2982 }
2983 DataRowChangeEventArgs args = null;
2984 if (row._newRecord != -1)
2985 {
2986 row._tempRecord = row._newRecord;
2987 row._newRecord = -1;
2988 try
2989 {
2990 args = RaiseRowChanging(null, row, DataRowAction.Add, fireEvent: true);
2991 }
2992 catch
2993 {
2994 row._tempRecord = -1;
2995 throw;
2996 }
2997 row._newRecord = row._tempRecord;
2998 row._tempRecord = -1;
2999 }
3000 if (row._oldRecord != -1)
3001 {
3002 _recordManager[row._oldRecord] = row;
3003 }
3004 if (row._newRecord != -1)
3005 {
3006 _recordManager[row._newRecord] = row;
3007 }
3008 Rows.ArrayAdd(row);
3009 if (row.RowState == DataRowState.Unchanged)
3010 {
3011 RecordStateChanged(row._oldRecord, DataViewRowState.None, DataViewRowState.Unchanged);
3012 }
3013 else
3014 {
3015 RecordStateChanged(row._oldRecord, DataViewRowState.None, row.GetRecordState(row._oldRecord), row._newRecord, DataViewRowState.None, row.GetRecordState(row._newRecord));
3016 }
3017 if (_dependentColumns != null && _dependentColumns.Count > 0)
3018 {
3019 EvaluateExpressions(row, DataRowAction.Add, null);
3020 }
3021 RaiseRowChanged(args, row, DataRowAction.Add);
3022 }
3023 finally
3024 {
3025 DataCommonEventSource.Log.ExitScope(scopeId);
3026 }
3027 }
void Add(TKey key, TValue value)
DataRowCollection Rows
Definition DataTable.cs:701
DataRowChangeEventArgs RaiseRowChanging(DataRowChangeEventArgs args, DataRow eRow, DataRowAction eAction)
List< DataColumn > _dependentColumns
Definition DataTable.cs:160
void RecordStateChanged(int record, DataViewRowState oldState, DataViewRowState newState)
readonly RecordManager _recordManager
Definition DataTable.cs:74
DataRowChangeEventArgs RaiseRowChanged(DataRowChangeEventArgs args, DataRow eRow, DataRowAction eAction)

References System.Data.DataTable._dependentColumns, System.Data.DataTable._nextRowID, System.Data.DataTable._recordManager, System.Collections.Generic.Dictionary< TKey, TValue >.Add(), System.Data.DataRowCollection.ArrayAdd(), System.Collections.Generic.Dictionary< TKey, TValue >.Count, System.Runtime.Serialization.Dictionary, System.Data.DataTable.EvaluateExpressions(), System.Data.DataCommonEventSource.Log, System.Data.DataTable.ObjectID, System.Data.DataTable.RaiseRowChanged(), System.Data.DataTable.RaiseRowChanging(), System.Data.DataTable.RecordStateChanged(), System.Data.ExceptionBuilder.RowAlreadyInOtherCollection(), System.Data.ExceptionBuilder.RowAlreadyInTheCollection(), System.Data.ExceptionBuilder.RowEmpty(), and System.Data.DataTable.Rows.