Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
DataTable.cs
Go to the documentation of this file.
8using System.IO;
11using System.Text;
13using System.Xml;
16
17namespace System.Data;
18
20[ToolboxItem(false)]
21[DesignTimeVisible(false)]
22[DefaultProperty("TableName")]
23[DefaultEvent("RowChanging")]
24[Editor("Microsoft.VSDesigner.Data.Design.DataTableEditor, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
25[XmlSchemaProvider("GetDataTableSchema")]
26[TypeForwardedFrom("System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
27[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | DynamicallyAccessedMemberTypes.NonPublicConstructors)]
29{
30 internal struct RowDiffIdUsageSection
31 {
33
34 internal void Prepare(DataTable table)
35 {
36 _targetTable = table;
37 table._rowDiffId = null;
38 }
39 }
40
42 {
44
45 internal void Prepare(DataSet ds)
46 {
47 _targetDS = ds;
48 for (int i = 0; i < ds.Tables.Count; i++)
49 {
50 DataTable dataTable = ds.Tables[i];
52 }
53 }
54 }
55
57
59
60 internal long _nextRowID;
61
63
65
67
69
71
73
74 internal readonly RecordManager _recordManager;
75
76 internal readonly List<Index> _indexes;
77
79
80 private int _shadowCount;
81
83
84 private string _tableName = string.Empty;
85
86 internal string _tableNamespace;
87
88 private string _tablePrefix = string.Empty;
89
91
92 internal bool _fNestedInDataset = true;
93
95
96 private bool _cultureUserSet;
97
99
101
103
105
106 private bool _caseSensitive;
107
109
110 internal string _encodedTableName;
111
113
115
116 internal decimal _minOccurs = 1m;
117
118 internal decimal _maxOccurs = 1m;
119
120 internal bool _repeatableElement;
121
122 private object _typeName;
123
125
127
129
131
133
135
137
139
140 private bool _inDataLoad;
141
142 private bool _initialLoad;
143
144 private bool _enforceConstraints = true;
145
147
148 protected internal bool fInitInProgress;
149
150 internal bool _fInLoadDiffgram;
151
152 private byte _isTypedDataTable;
153
155
157
159
161
162 private bool _mergingData;
163
164 private DataRowChangeEventHandler _onRowChangedDelegate;
165
166 private DataRowChangeEventHandler _onRowChangingDelegate;
167
168 private DataRowChangeEventHandler _onRowDeletingDelegate;
169
170 private DataRowChangeEventHandler _onRowDeletedDelegate;
171
172 private DataColumnChangeEventHandler _onColumnChangedDelegate;
173
174 private DataColumnChangeEventHandler _onColumnChangingDelegate;
175
176 private DataTableClearEventHandler _onTableClearingDelegate;
177
178 private DataTableClearEventHandler _onTableClearedDelegate;
179
180 private DataTableNewRowEventHandler _onTableNewRowDelegate;
181
182 private PropertyChangedEventHandler _onPropertyChangingDelegate;
183
184 private EventHandler _onInitialized;
185
186 private readonly DataRowBuilder _rowBuilder;
187
188 internal readonly List<DataView> _delayedViews = new List<DataView>();
189
191
193
195
197
199
200 private static int s_objectTypeCount;
201
203
204 public bool CaseSensitive
205 {
206 get
207 {
208 return _caseSensitive;
209 }
210 set
211 {
212 if (_caseSensitive != value)
213 {
218 if (DataSet != null && !DataSet.ValidateCaseConstraint())
219 {
223 }
225 }
227 }
228 }
229
231
232 [Browsable(false)]
234
235 private bool IsTypedDataTable
236 {
237 get
238 {
239 switch (_isTypedDataTable)
240 {
241 case 0:
242 _isTypedDataTable = (byte)((GetType() != typeof(DataTable)) ? 1u : 2u);
243 return 1 == _isTypedDataTable;
244 case 1:
245 return true;
246 default:
247 return false;
248 }
249 }
250 }
251
252 internal bool SelfNested
253 {
254 get
255 {
257 {
258 if (parentRelation.Nested && parentRelation.ParentTable == this)
259 {
260 return true;
261 }
262 }
263 return false;
264 }
265 }
266
269 {
270 get
271 {
273 {
274 int num = _indexes.Count - 1;
275 while (0 <= num)
276 {
277 Index index = _indexes[num];
278 if (index.RefCount <= 1)
279 {
280 index.RemoveRef();
281 }
282 num--;
283 }
284 }
285 return _indexes;
286 }
287 }
288
289 [DefaultValue(SerializationFormat.Xml)]
291 {
292 get
293 {
294 return _remotingFormat;
295 }
296 set
297 {
298 if (value != SerializationFormat.Binary && value != 0)
299 {
301 }
302 if (DataSet != null && value != DataSet.RemotingFormat)
303 {
305 }
307 }
308 }
309
311 {
312 get
313 {
315 }
316 set
317 {
319 }
320 }
321
322 [Browsable(false)]
325
328
330
333
335 [Browsable(false)]
337
338 [Browsable(false)]
340 {
341 get
342 {
344 if (dataView == null)
345 {
346 if (_dataSet != null)
347 {
349 }
350 else
351 {
352 dataView = new DataView(this, locked: true);
353 dataView.SetIndex2("", DataViewRowState.CurrentRows, null, fireEvent: true);
354 }
356 if (dataView == null)
357 {
359 }
360 }
361 return dataView;
362 }
363 }
364
365 [DefaultValue("")]
366 public string DisplayExpression
367 {
368 get
369 {
371 }
372 [RequiresUnreferencedCode("Members from types used in the expressions may be trimmed if not referenced directly.")]
374 set
375 {
376 _displayExpression = ((!string.IsNullOrEmpty(value)) ? new DataExpression(this, value) : null);
377 }
378 }
379
381 {
382 get
383 {
384 if (_displayExpression == null)
385 {
386 return string.Empty;
387 }
389 }
390 }
391
392 internal bool EnforceConstraints
393 {
394 get
395 {
397 {
398 return false;
399 }
400 if (_dataSet != null)
401 {
403 }
404 return _enforceConstraints;
405 }
406 set
407 {
408 if (_dataSet == null && _enforceConstraints != value)
409 {
410 if (value)
411 {
413 }
415 }
416 }
417 }
418
420 {
421 get
422 {
424 }
425 set
426 {
428 }
429 }
430
431 [Browsable(false)]
433
435 {
436 get
437 {
438 if (_formatProvider == null)
439 {
441 if (cultureInfo.IsNeutralCulture)
442 {
444 }
446 }
447 return _formatProvider;
448 }
449 }
450
451 [Browsable(false)]
452 public bool HasErrors
453 {
454 get
455 {
456 for (int i = 0; i < Rows.Count; i++)
457 {
458 if (Rows[i].HasErrors)
459 {
460 return true;
461 }
462 }
463 return false;
464 }
465 }
466
468 {
469 get
470 {
471 return _culture;
472 }
473 set
474 {
475 long scopeId = DataCommonEventSource.Log.EnterScope("<ds.DataTable.set_Locale|API> {0}", ObjectID);
476 try
477 {
478 bool cultureUserSet = true;
479 if (value == null)
480 {
481 cultureUserSet = false;
482 value = ((_dataSet != null) ? _dataSet.Locale : _culture);
483 }
484 if (_culture != value && !_culture.Equals(value))
485 {
486 bool flag = false;
487 bool flag2 = false;
490 try
491 {
492 _cultureUserSet = true;
495 {
496 flag = false;
498 flag = true;
499 }
500 }
501 catch
502 {
503 flag2 = true;
504 throw;
505 }
506 finally
507 {
508 if (!flag)
509 {
510 try
511 {
513 }
515 {
517 }
519 if (!flag2)
520 {
522 }
523 }
524 }
526 }
528 }
529 finally
530 {
531 DataCommonEventSource.Log.ExitScope(scopeId);
532 }
533 }
534 }
535
536 [DefaultValue(50)]
538 {
539 get
540 {
542 }
543 set
544 {
546 {
548 }
549 }
550 }
551
553
555 {
556 get
557 {
558 return _elementColumnCount;
559 }
560 set
561 {
562 if (value > 0 && _xmlText != null)
563 {
565 }
567 }
568 }
569
570 [Browsable(false)]
573
574 internal bool MergingData
575 {
576 get
577 {
578 return _mergingData;
579 }
580 set
581 {
583 }
584 }
585
587
589 {
590 get
591 {
592 int num = 0;
594 {
595 if (parentRelation.Nested)
596 {
597 num++;
598 }
599 }
600 return num;
601 }
602 }
603
604 [Editor("Microsoft.VSDesigner.Data.Design.PrimaryKeyEditor, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
607 {
608 get
609 {
611 if (primaryKey != null)
612 {
613 return primaryKey.Key.ToArray();
614 }
615 return Array.Empty<DataColumn>();
616 }
618 set
619 {
622 if (fInitInProgress && value != null)
623 {
625 return;
626 }
627 if (value != null && value.Length != 0)
628 {
629 int num = 0;
630 for (int i = 0; i < value.Length && value[i] != null; i++)
631 {
632 num++;
633 }
634 if (num != 0)
635 {
637 if (num != value.Length)
638 {
639 array = new DataColumn[num];
640 for (int j = 0; j < num; j++)
641 {
642 array[j] = value[j];
643 }
644 }
646 if (uniqueConstraint.Table != this)
647 {
649 }
650 }
651 }
653 {
654 return;
655 }
657 {
658 uniqueConstraint.ColumnsReference.CopyTo(uniqueConstraint2.Key.ColumnsReference, 0);
660 }
662 _primaryKey = null;
663 if (primaryKey != null)
664 {
665 primaryKey.ConstraintIndex.RemoveRef();
666 if (_loadIndex != null)
667 {
669 _loadIndex = null;
670 }
671 if (_loadIndexwithOriginalAdded != null)
672 {
675 }
677 {
680 }
682 }
683 if (uniqueConstraint != null && uniqueConstraint2 == null)
684 {
686 }
688 _primaryIndex = ((uniqueConstraint != null) ? uniqueConstraint.Key.GetIndexDesc() : Array.Empty<IndexField>());
689 if (_primaryKey != null)
690 {
691 uniqueConstraint.ConstraintIndex.AddRef();
692 for (int k = 0; k < uniqueConstraint.ColumnsReference.Length; k++)
693 {
694 uniqueConstraint.ColumnsReference[k].AllowDBNull = false;
695 }
696 }
697 }
698 }
699
700 [Browsable(false)]
702
704 [DefaultValue("")]
705 public string TableName
706 {
707 get
708 {
709 return _tableName;
710 }
712 set
713 {
714 long scopeId = DataCommonEventSource.Log.EnterScope("<ds.DataTable.set_TableName|API> {0}, value='{1}'", ObjectID, value);
715 try
716 {
717 if (value == null)
718 {
719 value = string.Empty;
720 }
722 if (string.Compare(_tableName, value, ignoreCase: true, locale) != 0)
723 {
724 if (_dataSet != null)
725 {
726 if (value.Length == 0)
727 {
729 }
731 {
733 }
735 if (nestedParentRelations.Length == 0)
736 {
738 }
739 else
740 {
742 foreach (DataRelation dataRelation in array)
743 {
744 if (!dataRelation.ParentTable.Columns.CanRegisterName(value))
745 {
747 }
748 }
752 {
753 dataRelation2.ParentTable.Columns.RegisterColumnName(value, null);
754 dataRelation2.ParentTable.Columns.UnregisterName(TableName);
755 }
756 }
757 if (_tableName.Length != 0)
758 {
760 }
761 }
762 RaisePropertyChanging("TableName");
764 _encodedTableName = null;
765 }
766 else if (string.Compare(_tableName, value, ignoreCase: false, locale) != 0)
767 {
768 RaisePropertyChanging("TableName");
770 _encodedTableName = null;
771 }
772 }
773 finally
774 {
775 DataCommonEventSource.Log.ExitScope(scopeId);
776 }
777 }
778 }
779
780 internal string EncodedTableName
781 {
782 get
783 {
784 string text = _encodedTableName;
785 if (text == null)
786 {
788 }
789 return text;
790 }
791 }
792
793 public string Namespace
794 {
795 get
796 {
798 }
800 set
801 {
802 long scopeId = DataCommonEventSource.Log.EnterScope("<ds.DataTable.set_Namespace|API> {0}, value='{1}'", ObjectID, value);
803 try
804 {
805 if (value != _tableNamespace)
806 {
807 if (_dataSet != null)
808 {
809 string text = ((value == null) ? GetInheritedNamespace(new List<DataTable>()) : value);
810 if (text != Namespace)
811 {
813 {
815 }
817 }
818 }
821 }
823 }
824 finally
825 {
826 DataCommonEventSource.Log.ExitScope(scopeId);
827 }
828 }
829 }
830
831 [DefaultValue("")]
832 public string Prefix
833 {
834 get
835 {
836 return _tablePrefix;
837 }
839 set
840 {
841 if (value == null)
842 {
843 value = string.Empty;
844 }
845 DataCommonEventSource.Log.Trace("<ds.DataTable.set_Prefix|API> {0}, value='{1}'", ObjectID, value);
847 {
849 }
851 }
852 }
853
855 {
856 get
857 {
858 return _xmlText;
859 }
860 set
861 {
862 if (_xmlText == value)
863 {
864 return;
865 }
866 if (_xmlText != null)
867 {
868 if (value != null)
869 {
871 }
873 }
874 else if (value != Columns[value.ColumnName])
875 {
877 }
878 _xmlText = value;
879 }
880 }
881
882 internal decimal MaxOccurs
883 {
884 get
885 {
886 return _maxOccurs;
887 }
888 set
889 {
891 }
892 }
893
894 internal decimal MinOccurs
895 {
896 get
897 {
898 return _minOccurs;
899 }
900 set
901 {
903 }
904 }
905
906 [Browsable(false)]
908 public override ISite? Site
909 {
910 get
911 {
912 return base.Site;
913 }
914 set
915 {
916 ISite site = Site;
917 if (value == null && site != null)
918 {
919 IContainer container = site.Container;
920 if (container != null)
921 {
922 for (int i = 0; i < Columns.Count; i++)
923 {
924 if (Columns[i].Site != null)
925 {
926 container.Remove(Columns[i]);
927 }
928 }
929 }
930 }
932 }
933 }
934
936
938 {
939 get
940 {
942 {
943 return _onColumnChangedDelegate != null;
944 }
945 return true;
946 }
947 }
948
950 {
951 get
952 {
953 if (_typeName != null)
954 {
956 }
957 return XmlQualifiedName.Empty;
958 }
959 set
960 {
962 }
963 }
964
966 {
967 get
968 {
969 if (_rowDiffId == null)
970 {
971 _rowDiffId = new Hashtable();
972 }
973 return _rowDiffId;
974 }
975 }
976
977 internal int ObjectID => _objectID;
978
979 public event DataColumnChangeEventHandler? ColumnChanging
980 {
981 add
982 {
983 DataCommonEventSource.Log.Trace("<ds.DataTable.add_ColumnChanging|API> {0}", ObjectID);
985 }
986 remove
987 {
988 DataCommonEventSource.Log.Trace("<ds.DataTable.remove_ColumnChanging|API> {0}", ObjectID);
990 }
991 }
992
993 public event DataColumnChangeEventHandler? ColumnChanged
994 {
995 add
996 {
997 DataCommonEventSource.Log.Trace("<ds.DataTable.add_ColumnChanged|API> {0}", ObjectID);
999 }
1000 remove
1001 {
1002 DataCommonEventSource.Log.Trace("<ds.DataTable.remove_ColumnChanged|API> {0}", ObjectID);
1004 }
1005 }
1006
1007 public event EventHandler? Initialized
1008 {
1009 add
1010 {
1012 }
1013 remove
1014 {
1016 }
1017 }
1018
1019 internal event PropertyChangedEventHandler PropertyChanging
1020 {
1021 add
1022 {
1023 DataCommonEventSource.Log.Trace("<ds.DataTable.add_PropertyChanging|INFO> {0}", ObjectID);
1025 }
1026 remove
1027 {
1028 DataCommonEventSource.Log.Trace("<ds.DataTable.remove_PropertyChanging|INFO> {0}", ObjectID);
1030 }
1031 }
1032
1033 public event DataRowChangeEventHandler? RowChanged
1034 {
1035 add
1036 {
1037 DataCommonEventSource.Log.Trace("<ds.DataTable.add_RowChanged|API> {0}", ObjectID);
1039 }
1040 remove
1041 {
1042 DataCommonEventSource.Log.Trace("<ds.DataTable.remove_RowChanged|API> {0}", ObjectID);
1044 }
1045 }
1046
1047 public event DataRowChangeEventHandler? RowChanging
1048 {
1049 add
1050 {
1051 DataCommonEventSource.Log.Trace("<ds.DataTable.add_RowChanging|API> {0}", ObjectID);
1053 }
1054 remove
1055 {
1056 DataCommonEventSource.Log.Trace("<ds.DataTable.remove_RowChanging|API> {0}", ObjectID);
1058 }
1059 }
1060
1061 public event DataRowChangeEventHandler? RowDeleting
1062 {
1063 add
1064 {
1065 DataCommonEventSource.Log.Trace("<ds.DataTable.add_RowDeleting|API> {0}", ObjectID);
1067 }
1068 remove
1069 {
1070 DataCommonEventSource.Log.Trace("<ds.DataTable.remove_RowDeleting|API> {0}", ObjectID);
1072 }
1073 }
1074
1075 public event DataRowChangeEventHandler? RowDeleted
1076 {
1077 add
1078 {
1079 DataCommonEventSource.Log.Trace("<ds.DataTable.add_RowDeleted|API> {0}", ObjectID);
1081 }
1082 remove
1083 {
1084 DataCommonEventSource.Log.Trace("<ds.DataTable.remove_RowDeleted|API> {0}", ObjectID);
1086 }
1087 }
1088
1089 public event DataTableClearEventHandler? TableClearing
1090 {
1091 add
1092 {
1093 DataCommonEventSource.Log.Trace("<ds.DataTable.add_TableClearing|API> {0}", ObjectID);
1095 }
1096 remove
1097 {
1098 DataCommonEventSource.Log.Trace("<ds.DataTable.remove_TableClearing|API> {0}", ObjectID);
1100 }
1101 }
1102
1103 public event DataTableClearEventHandler? TableCleared
1104 {
1105 add
1106 {
1107 DataCommonEventSource.Log.Trace("<ds.DataTable.add_TableCleared|API> {0}", ObjectID);
1109 }
1110 remove
1111 {
1112 DataCommonEventSource.Log.Trace("<ds.DataTable.remove_TableCleared|API> {0}", ObjectID);
1114 }
1115 }
1116
1117 public event DataTableNewRowEventHandler? TableNewRow
1118 {
1119 add
1120 {
1122 }
1123 remove
1124 {
1126 }
1127 }
1128
1129 public DataTable()
1130 {
1131 GC.SuppressFinalize(this);
1132 DataCommonEventSource.Log.Trace("<ds.DataTable.DataTable|API> {0}", ObjectID);
1133 _nextRowID = 1L;
1134 _recordManager = new RecordManager(this);
1139 _indexes = new List<Index>();
1140 _rowBuilder = new DataRowBuilder(this, -1);
1141 }
1142
1143 public DataTable(string? tableName)
1144 : this()
1145 {
1146 _tableName = ((tableName == null) ? "" : tableName);
1147 }
1148
1149 public DataTable(string? tableName, string? tableNamespace)
1150 : this(tableName)
1151 {
1153 }
1154
1155 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2112:ReflectionToRequiresUnreferencedCode", Justification = "CreateInstance's use of GetType uses only the parameterless constructor. Warnings are about serialization related constructors.")]
1156 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
1158 : this()
1159 {
1163 while (enumerator.MoveNext())
1164 {
1165 string name = enumerator.Name;
1166 if (name == "DataTable.RemotingFormat")
1167 {
1169 }
1170 }
1172 }
1173
1174 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "Binary serialization is unsafe in general and is planned to be obsoleted. We do not want to mark interface or ctors of this class as unsafe as that would show many unnecessary warnings elsewhere.")]
1181
1182 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
1184 {
1185 info.AddValue("DataTable.RemotingVersion", new Version(2, 0));
1186 if (remotingFormat != 0)
1187 {
1188 info.AddValue("DataTable.RemotingFormat", remotingFormat);
1189 }
1190 if (remotingFormat != 0)
1191 {
1193 if (isSingleTable)
1194 {
1195 SerializeTableData(info, context, 0);
1196 }
1197 return;
1198 }
1199 string namespaceURI = string.Empty;
1200 bool flag = false;
1201 if (_dataSet == null)
1202 {
1203 DataSet dataSet = new DataSet("tmpDataSet");
1204 dataSet.SetLocaleValue(_culture, _cultureUserSet);
1207 dataSet.Tables.Add(this);
1208 flag = true;
1209 }
1210 else
1211 {
1214 }
1215 info.AddValue("XmlSchema", _dataSet.GetXmlSchemaForRemoting(this));
1216 info.AddValue("XmlDiffGram", _dataSet.GetRemotingDiffGram(this));
1217 if (flag)
1218 {
1219 _dataSet.Tables.Remove(this);
1220 }
1221 else
1222 {
1224 }
1225 }
1226
1227 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
1229 {
1230 if (remotingFormat != 0)
1231 {
1233 if (isSingleTable)
1234 {
1235 DeserializeTableData(info, context, 0);
1236 ResetIndexes();
1237 }
1238 return;
1239 }
1240 string text = (string)info.GetValue("XmlSchema", typeof(string));
1241 string text2 = (string)info.GetValue("XmlDiffGram", typeof(string));
1242 if (text != null)
1243 {
1244 DataSet dataSet = new DataSet();
1245 dataSet.ReadXmlSchema(new XmlTextReader(new StringReader(text)));
1246 DataTable dataTable = dataSet.Tables[0];
1247 dataTable.CloneTo(this, null, skipExpressionColumns: false);
1248 Namespace = dataTable.Namespace;
1249 if (text2 != null)
1250 {
1251 dataSet.Tables.Remove(dataSet.Tables[0]);
1252 dataSet.Tables.Add(this);
1253 dataSet.ReadXml(new XmlTextReader(new StringReader(text2)), XmlReadMode.DiffGram);
1254 dataSet.Tables.Remove(this);
1255 }
1256 }
1257 }
1258
1259 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
1261 {
1262 info.AddValue("DataTable.TableName", TableName);
1263 info.AddValue("DataTable.Namespace", Namespace);
1264 info.AddValue("DataTable.Prefix", Prefix);
1265 info.AddValue("DataTable.CaseSensitive", _caseSensitive);
1266 info.AddValue("DataTable.caseSensitiveAmbient", !_caseSensitiveUserSet);
1267 info.AddValue("DataTable.LocaleLCID", Locale.LCID);
1268 info.AddValue("DataTable.MinimumCapacity", _recordManager.MinimumCapacity);
1269 info.AddValue("DataTable.NestedInDataSet", _fNestedInDataset);
1270 info.AddValue("DataTable.TypeName", TypeName.ToString());
1271 info.AddValue("DataTable.RepeatableElement", _repeatableElement);
1272 info.AddValue("DataTable.ExtendedProperties", ExtendedProperties);
1273 info.AddValue("DataTable.Columns.Count", Columns.Count);
1274 if (isSingleTable)
1275 {
1277 list.Add(this);
1279 {
1281 }
1282 }
1284 for (int i = 0; i < Columns.Count; i++)
1285 {
1286 info.AddValue(string.Format(invariantCulture, "DataTable.DataColumn_{0}.ColumnName", i), Columns[i].ColumnName);
1287 info.AddValue(string.Format(invariantCulture, "DataTable.DataColumn_{0}.Namespace", i), Columns[i]._columnUri);
1288 info.AddValue(string.Format(invariantCulture, "DataTable.DataColumn_{0}.Prefix", i), Columns[i].Prefix);
1289 info.AddValue(string.Format(invariantCulture, "DataTable.DataColumn_{0}.ColumnMapping", i), Columns[i].ColumnMapping);
1290 info.AddValue(string.Format(invariantCulture, "DataTable.DataColumn_{0}.AllowDBNull", i), Columns[i].AllowDBNull);
1291 info.AddValue(string.Format(invariantCulture, "DataTable.DataColumn_{0}.AutoIncrement", i), Columns[i].AutoIncrement);
1292 info.AddValue(string.Format(invariantCulture, "DataTable.DataColumn_{0}.AutoIncrementStep", i), Columns[i].AutoIncrementStep);
1293 info.AddValue(string.Format(invariantCulture, "DataTable.DataColumn_{0}.AutoIncrementSeed", i), Columns[i].AutoIncrementSeed);
1294 info.AddValue(string.Format(invariantCulture, "DataTable.DataColumn_{0}.Caption", i), Columns[i].Caption);
1295 info.AddValue(string.Format(invariantCulture, "DataTable.DataColumn_{0}.DefaultValue", i), Columns[i].DefaultValue);
1296 info.AddValue(string.Format(invariantCulture, "DataTable.DataColumn_{0}.ReadOnly", i), Columns[i].ReadOnly);
1297 info.AddValue(string.Format(invariantCulture, "DataTable.DataColumn_{0}.MaxLength", i), Columns[i].MaxLength);
1298 info.AddValue(string.Format(invariantCulture, "DataTable.DataColumn_{0}.DataType_AssemblyQualifiedName", i), Columns[i].DataType.AssemblyQualifiedName);
1299 info.AddValue(string.Format(invariantCulture, "DataTable.DataColumn_{0}.XmlDataType", i), Columns[i].XmlDataType);
1300 info.AddValue(string.Format(invariantCulture, "DataTable.DataColumn_{0}.SimpleType", i), Columns[i].SimpleType);
1301 info.AddValue(string.Format(invariantCulture, "DataTable.DataColumn_{0}.DateTimeMode", i), Columns[i].DateTimeMode);
1302 info.AddValue(string.Format(invariantCulture, "DataTable.DataColumn_{0}.AutoIncrementCurrent", i), Columns[i].AutoIncrementCurrent);
1303 if (isSingleTable)
1304 {
1305 info.AddValue(string.Format(invariantCulture, "DataTable.DataColumn_{0}.Expression", i), Columns[i].Expression);
1306 }
1307 info.AddValue(string.Format(invariantCulture, "DataTable.DataColumn_{0}.ExtendedProperties", i), Columns[i]._extendedProperties);
1308 }
1309 if (isSingleTable)
1310 {
1311 SerializeConstraints(info, context, 0, allConstraints: false);
1312 }
1313 }
1314
1315 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
1317 {
1318 _tableName = info.GetString("DataTable.TableName");
1319 _tableNamespace = info.GetString("DataTable.Namespace");
1320 _tablePrefix = info.GetString("DataTable.Prefix");
1321 bool boolean = info.GetBoolean("DataTable.CaseSensitive");
1322 SetCaseSensitiveValue(boolean, userSet: true, resetIndexes: false);
1323 _caseSensitiveUserSet = !info.GetBoolean("DataTable.caseSensitiveAmbient");
1324 int culture = (int)info.GetValue("DataTable.LocaleLCID", typeof(int));
1327 _cultureUserSet = true;
1328 MinimumCapacity = info.GetInt32("DataTable.MinimumCapacity");
1329 _fNestedInDataset = info.GetBoolean("DataTable.NestedInDataSet");
1330 string @string = info.GetString("DataTable.TypeName");
1331 _typeName = new XmlQualifiedName(@string);
1332 _repeatableElement = info.GetBoolean("DataTable.RepeatableElement");
1333 _extendedProperties = (PropertyCollection)info.GetValue("DataTable.ExtendedProperties", typeof(PropertyCollection));
1334 int @int = info.GetInt32("DataTable.Columns.Count");
1335 string[] array = new string[@int];
1337 for (int i = 0; i < @int; i++)
1338 {
1340 dataColumn.ColumnName = info.GetString(string.Format(invariantCulture, "DataTable.DataColumn_{0}.ColumnName", i));
1341 dataColumn._columnUri = info.GetString(string.Format(invariantCulture, "DataTable.DataColumn_{0}.Namespace", i));
1342 dataColumn.Prefix = info.GetString(string.Format(invariantCulture, "DataTable.DataColumn_{0}.Prefix", i));
1343 string typeName = (string)info.GetValue(string.Format(invariantCulture, "DataTable.DataColumn_{0}.DataType_AssemblyQualifiedName", i), typeof(string));
1344 dataColumn.DataType = Type.GetType(typeName, throwOnError: true);
1345 dataColumn.XmlDataType = (string)info.GetValue(string.Format(invariantCulture, "DataTable.DataColumn_{0}.XmlDataType", i), typeof(string));
1346 dataColumn.SimpleType = (SimpleType)info.GetValue(string.Format(invariantCulture, "DataTable.DataColumn_{0}.SimpleType", i), typeof(SimpleType));
1347 dataColumn.ColumnMapping = (MappingType)info.GetValue(string.Format(invariantCulture, "DataTable.DataColumn_{0}.ColumnMapping", i), typeof(MappingType));
1348 dataColumn.DateTimeMode = (DataSetDateTime)info.GetValue(string.Format(invariantCulture, "DataTable.DataColumn_{0}.DateTimeMode", i), typeof(DataSetDateTime));
1349 dataColumn.AllowDBNull = info.GetBoolean(string.Format(invariantCulture, "DataTable.DataColumn_{0}.AllowDBNull", i));
1350 dataColumn.AutoIncrement = info.GetBoolean(string.Format(invariantCulture, "DataTable.DataColumn_{0}.AutoIncrement", i));
1351 dataColumn.AutoIncrementStep = info.GetInt64(string.Format(invariantCulture, "DataTable.DataColumn_{0}.AutoIncrementStep", i));
1352 dataColumn.AutoIncrementSeed = info.GetInt64(string.Format(invariantCulture, "DataTable.DataColumn_{0}.AutoIncrementSeed", i));
1353 dataColumn.Caption = info.GetString(string.Format(invariantCulture, "DataTable.DataColumn_{0}.Caption", i));
1354 dataColumn.DefaultValue = info.GetValue(string.Format(invariantCulture, "DataTable.DataColumn_{0}.DefaultValue", i), typeof(object));
1355 dataColumn.ReadOnly = info.GetBoolean(string.Format(invariantCulture, "DataTable.DataColumn_{0}.ReadOnly", i));
1356 dataColumn.MaxLength = info.GetInt32(string.Format(invariantCulture, "DataTable.DataColumn_{0}.MaxLength", i));
1357 dataColumn.AutoIncrementCurrent = info.GetValue(string.Format(invariantCulture, "DataTable.DataColumn_{0}.AutoIncrementCurrent", i), typeof(object));
1358 if (isSingleTable)
1359 {
1360 array[i] = info.GetString(string.Format(invariantCulture, "DataTable.DataColumn_{0}.Expression", i));
1361 }
1362 dataColumn._extendedProperties = (PropertyCollection)info.GetValue(string.Format(invariantCulture, "DataTable.DataColumn_{0}.ExtendedProperties", i), typeof(PropertyCollection));
1364 }
1365 if (isSingleTable)
1366 {
1367 for (int j = 0; j < @int; j++)
1368 {
1369 if (array[j] != null)
1370 {
1371 Columns[j].Expression = array[j];
1372 }
1373 }
1374 }
1375 if (isSingleTable)
1376 {
1377 DeserializeConstraints(info, context, 0, allConstraints: false);
1378 }
1379 }
1380
1382 {
1384 for (int i = 0; i < Constraints.Count; i++)
1385 {
1386 Constraint constraint = Constraints[i];
1387 if (constraint is UniqueConstraint uniqueConstraint)
1388 {
1389 int[] array = new int[uniqueConstraint.Columns.Length];
1390 for (int j = 0; j < array.Length; j++)
1391 {
1392 array[j] = uniqueConstraint.Columns[j].Ordinal;
1393 }
1395 arrayList2.Add("U");
1396 arrayList2.Add(uniqueConstraint.ConstraintName);
1398 arrayList2.Add(uniqueConstraint.IsPrimaryKey);
1399 arrayList2.Add(uniqueConstraint.ExtendedProperties);
1401 continue;
1402 }
1404 if (allConstraints || (foreignKeyConstraint.Table == this && foreignKeyConstraint.RelatedTable == this))
1405 {
1408 for (int k = 1; k < array2.Length; k++)
1409 {
1410 array2[k] = foreignKeyConstraint.RelatedColumns[k - 1].Ordinal;
1411 }
1412 int[] array3 = new int[foreignKeyConstraint.Columns.Length + 1];
1414 for (int l = 1; l < array3.Length; l++)
1415 {
1416 array3[l] = foreignKeyConstraint.Columns[l - 1].Ordinal;
1417 }
1419 arrayList3.Add("F");
1420 arrayList3.Add(foreignKeyConstraint.ConstraintName);
1423 arrayList3.Add(new int[3]
1424 {
1425 (int)foreignKeyConstraint.AcceptRejectRule,
1426 (int)foreignKeyConstraint.UpdateRule,
1427 (int)foreignKeyConstraint.DeleteRule
1428 });
1429 arrayList3.Add(foreignKeyConstraint.ExtendedProperties);
1431 }
1432 }
1433 info.AddValue(string.Format(CultureInfo.InvariantCulture, "DataTable_{0}.Constraints", serIndex), arrayList);
1434 }
1435
1437 {
1438 ArrayList arrayList = (ArrayList)info.GetValue(string.Format(CultureInfo.InvariantCulture, "DataTable_{0}.Constraints", serIndex), typeof(ArrayList));
1439 foreach (ArrayList item in arrayList)
1440 {
1441 string text = (string)item[0];
1442 if (text.Equals("U"))
1443 {
1444 string name = (string)item[1];
1445 int[] array = (int[])item[2];
1446 bool isPrimaryKey = (bool)item[3];
1448 DataColumn[] array2 = new DataColumn[array.Length];
1449 for (int i = 0; i < array.Length; i++)
1450 {
1451 array2[i] = Columns[array[i]];
1452 }
1456 continue;
1457 }
1458 string constraintName = (string)item[1];
1459 int[] array3 = (int[])item[2];
1460 int[] array4 = (int[])item[3];
1461 int[] array5 = (int[])item[4];
1465 for (int j = 0; j < array6.Length; j++)
1466 {
1467 array6[j] = dataTable.Columns[array3[j + 1]];
1468 }
1471 for (int k = 0; k < array7.Length; k++)
1472 {
1473 array7[k] = dataTable2.Columns[array4[k + 1]];
1474 }
1481 }
1482 }
1483
1485 {
1486 int count = Columns.Count;
1487 for (int i = 0; i < count; i++)
1488 {
1489 info.AddValue(string.Format(CultureInfo.InvariantCulture, "DataTable_{0}.DataColumn_{1}.Expression", serIndex, i), Columns[i].Expression);
1490 }
1491 }
1492
1493 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
1495 {
1496 int count = Columns.Count;
1497 for (int i = 0; i < count; i++)
1498 {
1499 string @string = info.GetString(string.Format(CultureInfo.InvariantCulture, "DataTable_{0}.DataColumn_{1}.Expression", serIndex, i));
1500 if (@string.Length != 0)
1501 {
1502 Columns[i].Expression = @string;
1503 }
1504 }
1505 }
1506
1507 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
1509 {
1510 int count = Columns.Count;
1511 int count2 = Rows.Count;
1512 int num = 0;
1513 int num2 = 0;
1514 BitArray bitArray = new BitArray(count2 * 3, defaultValue: false);
1515 for (int i = 0; i < count2; i++)
1516 {
1517 int num3 = i * 3;
1518 DataRow dataRow = Rows[i];
1519 DataRowState rowState = dataRow.RowState;
1520 switch (rowState)
1521 {
1522 case DataRowState.Added:
1523 bitArray[num3 + 1] = true;
1524 break;
1525 case DataRowState.Modified:
1526 bitArray[num3] = true;
1527 num++;
1528 break;
1529 case DataRowState.Deleted:
1530 bitArray[num3] = true;
1531 bitArray[num3 + 1] = true;
1532 break;
1533 default:
1535 case DataRowState.Unchanged:
1536 break;
1537 }
1538 if (-1 != dataRow._tempRecord)
1539 {
1540 bitArray[num3 + 2] = true;
1541 num2++;
1542 }
1543 }
1544 int num4 = count2 + num + num2;
1547 if (num4 > 0)
1548 {
1549 for (int j = 0; j < count; j++)
1550 {
1551 object emptyColumnStore = Columns[j].GetEmptyColumnStore(num4);
1553 BitArray value = new BitArray(num4);
1555 }
1556 }
1557 int num5 = 0;
1558 Hashtable hashtable = new Hashtable();
1560 for (int k = 0; k < count2; k++)
1561 {
1562 int num6 = Rows[k].CopyValuesIntoStore(arrayList, arrayList2, num5);
1563 GetRowAndColumnErrors(k, hashtable, hashtable2);
1564 num5 += num6;
1565 }
1567 info.AddValue(string.Format(invariantCulture, "DataTable_{0}.Rows.Count", serIndex), count2);
1568 info.AddValue(string.Format(invariantCulture, "DataTable_{0}.Records.Count", serIndex), num4);
1569 info.AddValue(string.Format(invariantCulture, "DataTable_{0}.RowStates", serIndex), bitArray);
1570 info.AddValue(string.Format(invariantCulture, "DataTable_{0}.Records", serIndex), arrayList);
1571 info.AddValue(string.Format(invariantCulture, "DataTable_{0}.NullBits", serIndex), arrayList2);
1572 info.AddValue(string.Format(invariantCulture, "DataTable_{0}.RowErrors", serIndex), hashtable);
1573 info.AddValue(string.Format(invariantCulture, "DataTable_{0}.ColumnErrors", serIndex), hashtable2);
1574 }
1575
1576 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
1578 {
1580 bool inDataLoad = _inDataLoad;
1581 try
1582 {
1583 _enforceConstraints = false;
1584 _inDataLoad = true;
1586 int @int = info.GetInt32(string.Format(invariantCulture, "DataTable_{0}.Rows.Count", serIndex));
1587 int int2 = info.GetInt32(string.Format(invariantCulture, "DataTable_{0}.Records.Count", serIndex));
1588 BitArray bitArray = (BitArray)info.GetValue(string.Format(invariantCulture, "DataTable_{0}.RowStates", serIndex), typeof(BitArray));
1589 ArrayList arrayList = (ArrayList)info.GetValue(string.Format(invariantCulture, "DataTable_{0}.Records", serIndex), typeof(ArrayList));
1590 ArrayList arrayList2 = (ArrayList)info.GetValue(string.Format(invariantCulture, "DataTable_{0}.NullBits", serIndex), typeof(ArrayList));
1591 Hashtable hashtable = (Hashtable)info.GetValue(string.Format(invariantCulture, "DataTable_{0}.RowErrors", serIndex), typeof(Hashtable));
1592 hashtable.OnDeserialization(this);
1593 Hashtable hashtable2 = (Hashtable)info.GetValue(string.Format(invariantCulture, "DataTable_{0}.ColumnErrors", serIndex), typeof(Hashtable));
1595 if (int2 <= 0)
1596 {
1597 return;
1598 }
1599 for (int i = 0; i < Columns.Count; i++)
1600 {
1601 Columns[i].SetStorage(arrayList[i], (BitArray)arrayList2[i]);
1602 }
1603 int num = 0;
1604 DataRow[] array = new DataRow[int2];
1605 for (int j = 0; j < @int; j++)
1606 {
1607 DataRow dataRow = (array[num] = NewEmptyRow());
1608 int num2 = j * 3;
1610 {
1611 case DataRowState.Unchanged:
1612 dataRow._oldRecord = num;
1613 dataRow._newRecord = num;
1614 num++;
1615 break;
1616 case DataRowState.Added:
1617 dataRow._oldRecord = -1;
1618 dataRow._newRecord = num;
1619 num++;
1620 break;
1621 case DataRowState.Modified:
1622 dataRow._oldRecord = num;
1623 dataRow._newRecord = num + 1;
1624 array[num + 1] = dataRow;
1625 num += 2;
1626 break;
1627 case DataRowState.Deleted:
1628 dataRow._oldRecord = num;
1629 dataRow._newRecord = -1;
1630 num++;
1631 break;
1632 }
1633 if (bitArray[num2 + 2])
1634 {
1635 dataRow._tempRecord = num;
1636 array[num] = dataRow;
1637 num++;
1638 }
1639 else
1640 {
1642 }
1645 _nextRowID++;
1646 ConvertToRowError(j, hashtable, hashtable2);
1647 }
1649 ResetIndexes();
1650 }
1651 finally
1652 {
1655 }
1656 }
1657
1659 {
1660 bool flag = bitStates[bitIndex];
1661 bool flag2 = bitStates[bitIndex + 1];
1662 if (!flag && !flag2)
1663 {
1664 return DataRowState.Unchanged;
1665 }
1666 if (!flag && flag2)
1667 {
1668 return DataRowState.Added;
1669 }
1670 if (flag && !flag2)
1671 {
1672 return DataRowState.Modified;
1673 }
1674 if (flag && flag2)
1675 {
1676 return DataRowState.Deleted;
1677 }
1679 }
1680
1682 {
1684 if (!dataRow.HasErrors)
1685 {
1686 return;
1687 }
1688 rowErrors.Add(rowIndex, dataRow.RowError);
1689 DataColumn[] columnsInError = dataRow.GetColumnsInError();
1690 if (columnsInError.Length != 0)
1691 {
1692 int[] array = new int[columnsInError.Length];
1693 string[] array2 = new string[columnsInError.Length];
1694 for (int i = 0; i < columnsInError.Length; i++)
1695 {
1696 array[i] = columnsInError[i].Ordinal;
1697 array2[i] = dataRow.GetColumnError(columnsInError[i]);
1698 }
1703 }
1704 }
1705
1706 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
1708 {
1711 {
1713 }
1715 {
1717 int[] array = (int[])arrayList[0];
1718 string[] array2 = (string[])arrayList[1];
1719 for (int i = 0; i < array.Length; i++)
1720 {
1721 dataRow.SetColumnError(array[i], array2[i]);
1722 }
1723 }
1724 }
1725
1726 internal void RestoreIndexEvents(bool forceReset)
1727 {
1728 DataCommonEventSource.Log.Trace("<ds.DataTable.RestoreIndexEvents|Info> {0}, {1}", ObjectID, _suspendIndexEvents);
1729 if (0 >= _suspendIndexEvents)
1730 {
1731 return;
1732 }
1734 if (_suspendIndexEvents != 0)
1735 {
1736 return;
1737 }
1738 Exception ex = null;
1740 try
1741 {
1743 for (int i = 0; i < count; i++)
1744 {
1746 try
1747 {
1748 if (forceReset || index.HasRemoteAggregate)
1749 {
1750 index.Reset();
1751 }
1752 else
1753 {
1754 index.FireResetEvent();
1755 }
1756 }
1758 {
1760 if (ex2 == null)
1761 {
1762 ex = ex2;
1763 }
1764 }
1765 }
1766 if (ex != null)
1767 {
1768 throw ex;
1769 }
1770 }
1771 finally
1772 {
1774 }
1775 }
1776
1777 internal void SuspendIndexEvents()
1778 {
1779 DataCommonEventSource.Log.Trace("<ds.DataTable.SuspendIndexEvents|Info> {0}, {1}", ObjectID, _suspendIndexEvents);
1781 }
1782
1784 {
1786 {
1788 if (isCaseSensitive)
1789 {
1791 }
1792 else
1793 {
1795 }
1796 if (resetIndexes)
1797 {
1798 ResetIndexes();
1799 foreach (Constraint constraint in Constraints)
1800 {
1801 constraint.CheckConstraint();
1802 }
1803 }
1804 return true;
1805 }
1806 return false;
1807 }
1808
1810 {
1811 return _caseSensitiveUserSet;
1812 }
1813
1814 private void ResetConstraints()
1815 {
1817 }
1818
1820 {
1821 if (_dataSet != dataSet)
1822 {
1823 _dataSet = dataSet;
1825 for (int i = 0; i < columns.Count; i++)
1826 {
1827 columns[i].OnSetDataSet();
1828 }
1829 if (DataSet != null)
1830 {
1831 _defaultView = null;
1832 }
1833 if (dataSet != null)
1834 {
1835 _remotingFormat = dataSet.RemotingFormat;
1836 }
1837 }
1838 }
1839
1840 internal void EnableConstraints()
1841 {
1842 bool flag = false;
1843 foreach (Constraint constraint in Constraints)
1844 {
1845 if (constraint is UniqueConstraint)
1846 {
1847 flag |= constraint.IsConstraintViolated();
1848 }
1849 }
1850 foreach (DataColumn column in Columns)
1851 {
1852 if (!column.AllowDBNull)
1853 {
1854 flag |= column.IsNotAllowDBNullViolated();
1855 }
1856 if (column.MaxLength >= 0)
1857 {
1858 flag |= column.IsMaxLengthViolated();
1859 }
1860 }
1861 if (flag)
1862 {
1863 EnforceConstraints = false;
1865 }
1866 }
1867
1869 {
1871 {
1872 _culture = culture;
1873 _compareInfo = null;
1874 _formatProvider = null;
1875 _hashCodeProvider = null;
1876 foreach (DataColumn column in Columns)
1877 {
1879 }
1880 if (resetIndexes)
1881 {
1882 ResetIndexes();
1883 foreach (Constraint constraint in Constraints)
1884 {
1885 constraint.CheckConstraint();
1886 }
1887 }
1888 return true;
1889 }
1890 return false;
1891 }
1892
1894 {
1895 return _cultureUserSet;
1896 }
1897
1902
1904 {
1905 List<DataRelation> list = null;
1907 {
1908 if (parentRelation.Nested)
1909 {
1910 if (list == null)
1911 {
1912 list = new List<DataRelation>();
1913 }
1914 list.Add(parentRelation);
1915 }
1916 }
1917 if (list != null && list.Count != 0)
1918 {
1919 return list.ToArray();
1920 }
1921 return Array.Empty<DataRelation>();
1922 }
1923
1925 {
1927 if (nestedParentRelations.Length != 0)
1928 {
1930 {
1931 if (dataRelation.ParentTable._tableNamespace != null)
1932 {
1933 return dataRelation.ParentTable._tableNamespace;
1934 }
1935 }
1936 int j;
1937 for (j = 0; j < nestedParentRelations.Length && (nestedParentRelations[j].ParentTable == this || visitedTables.Contains(nestedParentRelations[j].ParentTable)); j++)
1938 {
1939 }
1940 if (j < nestedParentRelations.Length)
1941 {
1944 {
1946 }
1947 return parentTable.GetInheritedNamespace(visitedTables);
1948 }
1949 }
1950 if (DataSet != null)
1951 {
1952 return DataSet.Namespace;
1953 }
1954 return string.Empty;
1955 }
1956
1957 internal bool IsNamespaceInherited()
1958 {
1959 return _tableNamespace == null;
1960 }
1961
1963 {
1965 {
1966 if (childRelation.Nested && childRelation.ChildTable != this && childRelation.ChildTable._tableNamespace == null)
1967 {
1968 DataTable childTable = childRelation.ChildTable;
1970 {
1972 }
1973 childTable.CheckCascadingNamespaceConflict(realNamespace);
1974 }
1975 }
1976 }
1977
1979 {
1981 {
1982 if (childRelation.Nested)
1983 {
1984 if (realNamespace != null)
1985 {
1986 childRelation.ChildTable.CheckNamespaceValidityForNestedParentRelations(realNamespace, this);
1987 }
1988 else
1989 {
1990 childRelation.ChildTable.CheckNamespaceValidityForNestedParentRelations(GetInheritedNamespace(new List<DataTable>()), this);
1991 }
1992 }
1993 }
1994 if (realNamespace == null)
1995 {
1997 }
1998 }
1999
2001 {
2003 {
2004 if (parentRelation.Nested && parentRelation.ParentTable != parentTable && parentRelation.ParentTable.Namespace != ns)
2005 {
2007 }
2008 }
2009 }
2010
2012 {
2013 RaisePropertyChanging("Namespace");
2014 foreach (DataColumn column in Columns)
2015 {
2016 if (column._columnUri == null)
2017 {
2018 column.RaisePropertyChanging("Namespace");
2019 }
2020 }
2022 {
2023 if (childRelation.Nested && childRelation.ChildTable != this)
2024 {
2025 childRelation.ChildTable.DoRaiseNamespaceChange();
2026 }
2027 }
2028 }
2029
2030 public virtual void BeginInit()
2031 {
2032 fInitInProgress = true;
2033 }
2034
2035 public virtual void EndInit()
2036 {
2037 if (_dataSet == null || !_dataSet._fInitInProgress)
2038 {
2041 foreach (DataColumn column in Columns)
2042 {
2043 if (column.Computed)
2044 {
2045 column.CopyExpressionFrom(column);
2046 }
2047 }
2048 }
2049 fInitInProgress = false;
2050 if (_delayedSetPrimaryKey != null)
2051 {
2053 _delayedSetPrimaryKey = null;
2054 }
2055 if (_delayedViews.Count > 0)
2056 {
2058 {
2059 delayedView.EndInit();
2060 }
2062 }
2063 OnInitialized();
2064 }
2065
2066 internal void SetKeyValues(DataKey key, object[] keyValues, int record)
2067 {
2068 for (int i = 0; i < keyValues.Length; i++)
2069 {
2070 key.ColumnsReference[i][record] = keyValues[i];
2071 }
2072 }
2073
2074 internal DataRow FindByIndex(Index ndx, object[] key)
2075 {
2076 Range range = ndx.FindRecords(key);
2077 if (!range.IsNull)
2078 {
2079 return _recordManager[ndx.GetRecord(range.Min)];
2080 }
2081 return null;
2082 }
2083
2085 {
2086 DataRow result = null;
2087 if (key.HasValue)
2088 {
2089 int record = ((row._oldRecord == -1) ? row._newRecord : row._oldRecord);
2090 object[] keyValues = key.GetKeyValues(record);
2091 result = FindByIndex(ndx, keyValues);
2092 }
2093 return result;
2094 }
2095
2097 {
2098 if (newRecord != -1)
2099 {
2102 return;
2103 }
2105 if (row._newRecord != -1)
2106 {
2108 }
2109 }
2110
2112 {
2113 if (targetRow == null)
2114 {
2117 targetRow._newRecord = targetRow._oldRecord;
2118 if (row._oldRecord != row._newRecord)
2119 {
2121 }
2122 InsertRow(targetRow, -1L);
2123 }
2124 else
2125 {
2126 int tempRecord = targetRow._tempRecord;
2128 try
2129 {
2130 DataRowState rowState = targetRow.RowState;
2131 int oldRecord = ((rowState == DataRowState.Added) ? targetRow._newRecord : (oldRecord = targetRow._oldRecord));
2132 if (targetRow.RowState == DataRowState.Unchanged && row.RowState == DataRowState.Unchanged)
2133 {
2134 int oldRecord2 = targetRow._oldRecord;
2135 int newRecord = (preserveChanges ? _recordManager.CopyRecord(this, oldRecord2, -1) : targetRow._newRecord);
2136 oldRecord2 = _recordManager.CopyRecord(row.Table, row._oldRecord, targetRow._oldRecord);
2138 }
2139 else if (row._newRecord == -1)
2140 {
2141 int oldRecord2 = targetRow._oldRecord;
2142 int newRecord = ((!preserveChanges) ? (-1) : ((targetRow.RowState == DataRowState.Unchanged) ? _recordManager.CopyRecord(this, oldRecord2, -1) : targetRow._newRecord));
2143 oldRecord2 = _recordManager.CopyRecord(row.Table, row._oldRecord, oldRecord2);
2144 if (oldRecord != ((rowState == DataRowState.Added) ? newRecord : oldRecord2))
2145 {
2147 idxSearch.Reset();
2149 }
2150 else
2151 {
2153 }
2154 }
2155 else
2156 {
2157 int oldRecord2 = targetRow._oldRecord;
2158 int newRecord = targetRow._newRecord;
2159 if (targetRow.RowState == DataRowState.Unchanged)
2160 {
2162 }
2163 oldRecord2 = _recordManager.CopyRecord(row.Table, row._oldRecord, oldRecord2);
2164 if (!preserveChanges)
2165 {
2166 newRecord = _recordManager.CopyRecord(row.Table, row._newRecord, newRecord);
2167 }
2169 }
2170 if (rowState == DataRowState.Added && targetRow._oldRecord != -1)
2171 {
2172 idxSearch.Reset();
2173 }
2174 }
2175 finally
2176 {
2178 }
2179 }
2180 if (row.HasErrors)
2181 {
2182 if (targetRow.RowError.Length == 0)
2183 {
2184 targetRow.RowError = row.RowError;
2185 }
2186 else
2187 {
2189 dataRow.RowError = dataRow.RowError + " ]:[ " + row.RowError;
2190 }
2191 DataColumn[] columnsInError = row.GetColumnsInError();
2192 for (int i = 0; i < columnsInError.Length; i++)
2193 {
2194 DataColumn column = targetRow.Table.Columns[columnsInError[i].ColumnName];
2195 targetRow.SetColumnError(column, row.GetColumnError(columnsInError[i]));
2196 }
2197 }
2198 else if (!preserveChanges)
2199 {
2200 targetRow.ClearErrors();
2201 }
2202 return targetRow;
2203 }
2204
2205 public void AcceptChanges()
2206 {
2207 long scopeId = DataCommonEventSource.Log.EnterScope("<ds.DataTable.AcceptChanges|API> {0}", ObjectID);
2208 try
2209 {
2210 DataRow[] array = new DataRow[Rows.Count];
2211 Rows.CopyTo(array, 0);
2213 try
2214 {
2215 for (int i = 0; i < array.Length; i++)
2216 {
2217 if (array[i].rowID != -1)
2218 {
2219 array[i].AcceptChanges();
2220 }
2221 }
2222 }
2223 finally
2224 {
2226 }
2227 }
2228 finally
2229 {
2230 DataCommonEventSource.Log.ExitScope(scopeId);
2231 }
2232 }
2233
2234 [MethodImpl(MethodImplOptions.NoInlining)]
2235 protected virtual DataTable CreateInstance()
2236 {
2237 return (DataTable)Activator.CreateInstance(GetType(), nonPublic: true);
2238 }
2239
2240 public virtual DataTable Clone()
2241 {
2242 return Clone(null);
2243 }
2244
2246 {
2247 long scopeId = DataCommonEventSource.Log.EnterScope("<ds.DataTable.Clone|INFO> {0}, cloneDS={1}", ObjectID, cloneDS?.ObjectID ?? 0);
2248 try
2249 {
2251 if (dataTable.Columns.Count > 0)
2252 {
2253 dataTable.Reset();
2254 }
2256 }
2257 finally
2258 {
2259 DataCommonEventSource.Log.ExitScope(scopeId);
2260 }
2261 }
2262
2264 {
2265 foreach (DataColumn column in sourceTable.Columns)
2266 {
2267 if (targetTable.Columns[column.ColumnName] == null)
2268 {
2269 targetTable.Columns.Add(column.Clone());
2270 }
2271 }
2272 return targetTable;
2273 }
2274
2276 {
2277 if (visitedMap == null)
2278 {
2279 visitedMap = new Hashtable();
2280 }
2282 {
2284 }
2285 DataTable dataTable = ds.Tables[sourceTable.TableName, sourceTable.Namespace];
2286 if (dataTable != null && dataTable.Columns.Count > 0)
2287 {
2289 }
2290 else
2291 {
2292 if (dataTable == null)
2293 {
2294 dataTable = new DataTable();
2295 ds.Tables.Add(dataTable);
2296 }
2298 }
2300 foreach (DataRelation childRelation in sourceTable.ChildRelations)
2301 {
2303 }
2304 return dataTable;
2305 }
2306
2308 {
2327 for (int i = 0; i < columns.Count; i++)
2328 {
2329 clone.Columns.Add(columns[i].Clone());
2330 }
2331 if (!skipExpressionColumns && cloneDS == null)
2332 {
2333 for (int j = 0; j < columns.Count; j++)
2334 {
2335 clone.Columns[columns[j].ColumnName].CopyExpressionFrom(columns[j]);
2336 }
2337 }
2339 if (primaryKey.Length != 0)
2340 {
2341 DataColumn[] array = new DataColumn[primaryKey.Length];
2342 for (int k = 0; k < primaryKey.Length; k++)
2343 {
2344 array[k] = clone.Columns[primaryKey[k].Ordinal];
2345 }
2347 }
2348 for (int l = 0; l < Constraints.Count; l++)
2349 {
2352 if (foreignKeyConstraint != null)
2353 {
2354 if (foreignKeyConstraint.Table != foreignKeyConstraint.RelatedTable)
2355 {
2356 continue;
2357 }
2359 if (foreignKeyConstraint2 != null)
2360 {
2361 Constraint constraint = clone.Constraints.FindConstraint(foreignKeyConstraint2);
2362 if (constraint != null)
2363 {
2364 constraint.ConstraintName = Constraints[l].ConstraintName;
2365 }
2366 }
2367 }
2368 else
2369 {
2370 if (uniqueConstraint == null)
2371 {
2372 continue;
2373 }
2375 if (uniqueConstraint2 == null)
2376 {
2377 continue;
2378 }
2379 Constraint constraint2 = clone.Constraints.FindConstraint(uniqueConstraint2);
2380 if (constraint2 == null)
2381 {
2382 continue;
2383 }
2384 constraint2.ConstraintName = Constraints[l].ConstraintName;
2385 foreach (object key in uniqueConstraint2.ExtendedProperties.Keys)
2386 {
2387 constraint2.ExtendedProperties[key] = uniqueConstraint2.ExtendedProperties[key];
2388 }
2389 }
2390 }
2391 for (int m = 0; m < Constraints.Count; m++)
2392 {
2393 if (clone.Constraints.Contains(Constraints[m].ConstraintName, caseSensitive: true))
2394 {
2395 continue;
2396 }
2399 if (foreignKeyConstraint3 != null)
2400 {
2401 if (foreignKeyConstraint3.Table == foreignKeyConstraint3.RelatedTable)
2402 {
2404 if (foreignKeyConstraint4 != null)
2405 {
2406 clone.Constraints.Add(foreignKeyConstraint4);
2407 }
2408 }
2409 }
2410 else if (uniqueConstraint3 != null)
2411 {
2412 clone.Constraints.Add(uniqueConstraint3.Clone(clone));
2413 }
2414 }
2415 if (_extendedProperties != null)
2416 {
2417 foreach (object key2 in _extendedProperties.Keys)
2418 {
2419 clone.ExtendedProperties[key2] = _extendedProperties[key2];
2420 }
2421 }
2422 return clone;
2423 }
2424
2426 {
2427 long scopeId = DataCommonEventSource.Log.EnterScope("<ds.DataTable.Copy|API> {0}", ObjectID);
2428 try
2429 {
2431 foreach (DataRow row in Rows)
2432 {
2434 }
2435 return dataTable;
2436 }
2437 finally
2438 {
2439 DataCommonEventSource.Log.ExitScope(scopeId);
2440 }
2441 }
2442
2444 {
2446 if (oldRecord == -1 && newRecord == -1)
2447 {
2448 dataRow = NewRow(-1);
2449 AddRow(dataRow);
2450 }
2451 else
2452 {
2453 dataRow = NewEmptyRow();
2456 InsertRow(dataRow, -1L);
2457 }
2458 return dataRow;
2459 }
2460
2461 internal void AddRow(DataRow row)
2462 {
2463 AddRow(row, -1);
2464 }
2465
2466 internal void AddRow(DataRow row, int proposedID)
2467 {
2468 InsertRow(row, proposedID, -1);
2469 }
2470
2471 internal void InsertRow(DataRow row, int proposedID, int pos)
2472 {
2473 InsertRow(row, proposedID, pos, fireEvent: true);
2474 }
2475
2476 internal void InsertRow(DataRow row, long proposedID, int pos, bool fireEvent)
2477 {
2479 if (row == null)
2480 {
2481 throw ExceptionBuilder.ArgumentNull("row");
2482 }
2483 if (row.Table != this)
2484 {
2486 }
2487 if (row.rowID != -1)
2488 {
2490 }
2491 row.BeginEdit();
2492 int tempRecord = row._tempRecord;
2493 row._tempRecord = -1;
2494 if (proposedID == -1)
2495 {
2497 }
2498 bool flag;
2499 if (flag = _nextRowID <= proposedID)
2500 {
2502 }
2503 try
2504 {
2505 try
2506 {
2509 }
2510 catch
2511 {
2512 if (flag && _nextRowID == proposedID + 1)
2513 {
2515 }
2516 row.rowID = -1L;
2518 throw;
2519 }
2520 if (deferredException != null)
2521 {
2522 throw deferredException;
2523 }
2524 if (!EnforceConstraints)
2525 {
2526 return;
2527 }
2529 for (int i = 0; i < count; i++)
2530 {
2532 if (dataColumn.Computed)
2533 {
2534 dataColumn.CheckColumnConstraint(row, DataRowAction.Add);
2535 }
2536 }
2537 }
2538 finally
2539 {
2540 row.ResetLastChangedColumn();
2541 }
2542 }
2543
2545 {
2546 if (row._tempRecord != -1)
2547 {
2548 row.EndEdit();
2549 }
2550 }
2551
2552 public void Clear()
2553 {
2554 Clear(clearAll: true);
2555 }
2556
2557 internal void Clear(bool clearAll)
2558 {
2559 long scopeId = DataCommonEventSource.Log.EnterScope("<ds.DataTable.Clear|INFO> {0}, clearAll={1}", ObjectID, clearAll);
2560 try
2561 {
2562 _rowDiffId = null;
2563 if (_dataSet != null)
2564 {
2566 }
2567 bool flag = Rows.Count != 0;
2568 DataTableClearEventArgs e = null;
2569 if (flag)
2570 {
2571 e = new DataTableClearEventArgs(this);
2572 OnTableClearing(e);
2573 }
2574 if (_dataSet != null && _dataSet.EnforceConstraints)
2575 {
2577 while (parentForeignKeyConstraintEnumerator.GetNext())
2578 {
2580 foreignKeyConstraint.CheckCanClearParentTable(this);
2581 }
2582 }
2583 _recordManager.Clear(clearAll);
2584 foreach (DataRow row in Rows)
2585 {
2586 row._oldRecord = -1;
2587 row._newRecord = -1;
2588 row._tempRecord = -1;
2589 row.rowID = -1L;
2590 row.RBTreeNodeId = 0;
2591 }
2592 Rows.ArrayClear();
2593 ResetIndexes();
2594 if (flag)
2595 {
2596 OnTableCleared(e);
2597 }
2598 foreach (DataColumn column in Columns)
2599 {
2601 }
2602 }
2603 finally
2604 {
2605 DataCommonEventSource.Log.ExitScope(scopeId);
2606 }
2607 }
2608
2610 {
2611 if (_dataSet != null && _dataSet._fEnableCascading)
2612 {
2614 while (parentForeignKeyConstraintEnumerator.GetNext())
2615 {
2616 parentForeignKeyConstraintEnumerator.GetForeignKeyConstraint().CheckCascade(row, action);
2617 }
2618 }
2619 }
2620
2621 internal void CommitRow(DataRow row)
2622 {
2624 if (!_inDataLoad)
2625 {
2626 CascadeAll(row, DataRowAction.Commit);
2627 }
2628 SetOldRecord(row, row._newRecord);
2630 }
2631
2632 internal int Compare(string s1, string s2)
2633 {
2634 return Compare(s1, s2, null);
2635 }
2636
2637 internal int Compare(string s1, string s2, CompareInfo comparer)
2638 {
2639 if ((object)s1 == s2)
2640 {
2641 return 0;
2642 }
2643 if (s1 == null)
2644 {
2645 return -1;
2646 }
2647 if (s2 == null)
2648 {
2649 return 1;
2650 }
2651 int num = s1.Length;
2652 int num2 = s2.Length;
2653 while (num > 0 && (s1[num - 1] == ' ' || s1[num - 1] == '\u3000'))
2654 {
2655 num--;
2656 }
2657 while (num2 > 0 && (s2[num2 - 1] == ' ' || s2[num2 - 1] == '\u3000'))
2658 {
2659 num2--;
2660 }
2661 return (comparer ?? CompareInfo).Compare(s1, 0, num, s2, 0, num2, _compareFlags);
2662 }
2663
2664 internal int IndexOf(string s1, string s2)
2665 {
2667 }
2668
2669 internal bool IsSuffix(string s1, string s2)
2670 {
2672 }
2673
2674 [RequiresUnreferencedCode("Members of types used in the filter or expression might be trimmed.")]
2675 public object Compute(string? expression, string? filter)
2676 {
2677 DataRow[] rows = Select(filter, "", DataViewRowState.CurrentRows);
2679 return dataExpression.Evaluate(rows);
2680 }
2681
2682 internal void CopyRow(DataTable table, DataRow row)
2683 {
2684 int num = -1;
2685 int newRecord = -1;
2686 if (row == null)
2687 {
2688 return;
2689 }
2690 if (row._oldRecord != -1)
2691 {
2692 num = table._recordManager.ImportRecord(row.Table, row._oldRecord);
2693 }
2694 if (row._newRecord != -1)
2695 {
2696 newRecord = ((row._newRecord == row._oldRecord) ? num : table._recordManager.ImportRecord(row.Table, row._newRecord));
2697 }
2698 DataRow dataRow = table.AddRecords(num, newRecord);
2699 if (row.HasErrors)
2700 {
2701 dataRow.RowError = row.RowError;
2702 DataColumn[] columnsInError = row.GetColumnsInError();
2703 for (int i = 0; i < columnsInError.Length; i++)
2704 {
2705 DataColumn column = dataRow.Table.Columns[columnsInError[i].ColumnName];
2706 dataRow.SetColumnError(column, row.GetColumnError(columnsInError[i]));
2707 }
2708 }
2709 }
2710
2711 internal void DeleteRow(DataRow row)
2712 {
2713 if (row._newRecord == -1)
2714 {
2716 }
2717 SetNewRecord(row, -1, DataRowAction.Delete);
2718 }
2719
2720 private void CheckPrimaryKey()
2721 {
2722 if (_primaryKey == null)
2723 {
2725 }
2726 }
2727
2729 {
2731 return FindRow(_primaryKey.Key, values);
2732 }
2733
2735 {
2737 return FindRow(_primaryKey.Key, value);
2738 }
2739
2740 private DataRow FindRow(DataKey key, object[] values)
2741 {
2743 Range range = index.FindRecords(values);
2744 if (range.IsNull)
2745 {
2746 return null;
2747 }
2748 return _recordManager[index.GetRecord(range.Min)];
2749 }
2750
2752 {
2754 Range range = index.FindRecords(value);
2755 if (range.IsNull)
2756 {
2757 return null;
2758 }
2759 return _recordManager[index.GetRecord(range.Min)];
2760 }
2761
2763 {
2765 for (int i = 0; i < indexDesc.Length; i++)
2766 {
2768 if (0 < stringBuilder.Length)
2769 {
2770 stringBuilder.Append(", ");
2771 }
2772 stringBuilder.Append(indexField.Column.ColumnName);
2773 if (indexField.IsDescending)
2774 {
2775 stringBuilder.Append(" DESC");
2776 }
2777 }
2778 return stringBuilder.ToString();
2779 }
2780
2781 internal void FreeRecord(ref int record)
2782 {
2784 }
2785
2787 {
2788 long scopeId = DataCommonEventSource.Log.EnterScope("<ds.DataTable.GetChanges|API> {0}", ObjectID);
2789 try
2790 {
2792 DataRow dataRow = null;
2793 for (int i = 0; i < Rows.Count; i++)
2794 {
2795 dataRow = Rows[i];
2796 if (dataRow._oldRecord != dataRow._newRecord)
2797 {
2798 dataTable.ImportRow(dataRow);
2799 }
2800 }
2801 if (dataTable.Rows.Count == 0)
2802 {
2803 return null;
2804 }
2805 return dataTable;
2806 }
2807 finally
2808 {
2809 DataCommonEventSource.Log.ExitScope(scopeId);
2810 }
2811 }
2812
2814 {
2815 long scopeId = DataCommonEventSource.Log.EnterScope("<ds.DataTable.GetChanges|API> {0}, rowStates={1}", ObjectID, rowStates);
2816 try
2817 {
2819 DataRow dataRow = null;
2820 for (int i = 0; i < Rows.Count; i++)
2821 {
2822 dataRow = Rows[i];
2823 if ((dataRow.RowState & rowStates) != 0)
2824 {
2825 dataTable.ImportRow(dataRow);
2826 }
2827 }
2828 if (dataTable.Rows.Count == 0)
2829 {
2830 return null;
2831 }
2832 return dataTable;
2833 }
2834 finally
2835 {
2836 DataCommonEventSource.Log.ExitScope(scopeId);
2837 }
2838 }
2839
2841 {
2843 for (int i = 0; i < Rows.Count; i++)
2844 {
2845 DataRow dataRow = Rows[i];
2846 if (dataRow.HasErrors)
2847 {
2848 list.Add(dataRow);
2849 }
2850 }
2851 DataRow[] array = NewRowArray(list.Count);
2852 list.CopyTo(array);
2853 return array;
2854 }
2855
2857 {
2858 return GetIndex(indexDesc, DataViewRowState.CurrentRows, null);
2859 }
2860
2865
2867 {
2869 try
2870 {
2871 for (int i = 0; i < _indexes.Count; i++)
2872 {
2873 Index index = _indexes[i];
2874 if (index != null && index.Equal(indexDesc, recordStates, rowFilter))
2875 {
2876 return index;
2877 }
2878 }
2879 }
2880 finally
2881 {
2883 }
2885 index2.AddRef();
2886 return index2;
2887 }
2888
2890 {
2891 return DefaultView;
2892 }
2893
2895 {
2896 return _dataViewListeners;
2897 }
2898
2899 internal int GetSpecialHashCode(string name)
2900 {
2901 int i;
2902 for (i = 0; i < name.Length && '\u3000' > name[i]; i++)
2903 {
2904 }
2905 if (name.Length == i)
2906 {
2907 if (_hashCodeProvider == null)
2908 {
2910 }
2911 return _hashCodeProvider.GetHashCode(name);
2912 }
2913 return 0;
2914 }
2915
2916 public void ImportRow(DataRow? row)
2917 {
2918 long scopeId = DataCommonEventSource.Log.EnterScope("<ds.DataTable.ImportRow|API> {0}", ObjectID);
2919 try
2920 {
2921 int num = -1;
2922 int num2 = -1;
2923 if (row == null)
2924 {
2925 return;
2926 }
2927 if (row._oldRecord != -1)
2928 {
2929 num = _recordManager.ImportRecord(row.Table, row._oldRecord);
2930 }
2931 if (row._newRecord != -1)
2932 {
2933 num2 = ((row.RowState == DataRowState.Unchanged) ? num : _recordManager.ImportRecord(row.Table, row._newRecord));
2934 }
2935 if (num == -1 && num2 == -1)
2936 {
2937 return;
2938 }
2940 if (row.HasErrors)
2941 {
2942 dataRow.RowError = row.RowError;
2943 DataColumn[] columnsInError = row.GetColumnsInError();
2944 for (int i = 0; i < columnsInError.Length; i++)
2945 {
2946 DataColumn column = dataRow.Table.Columns[columnsInError[i].ColumnName];
2947 dataRow.SetColumnError(column, row.GetColumnError(columnsInError[i]));
2948 }
2949 }
2950 }
2951 finally
2952 {
2953 DataCommonEventSource.Log.ExitScope(scopeId);
2954 }
2955 }
2956
2957 internal void InsertRow(DataRow row, long proposedID)
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 {
2965 }
2966 if (row.rowID != -1)
2967 {
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 }
2984 if (row._newRecord != -1)
2985 {
2986 row._tempRecord = row._newRecord;
2987 row._newRecord = -1;
2988 try
2989 {
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 {
3020 }
3022 }
3023 finally
3024 {
3025 DataCommonEventSource.Log.ExitScope(scopeId);
3026 }
3027 }
3028
3030 {
3031 IndexField[] indexDesc = key.GetIndexDesc();
3032 IndexField[] array = new IndexField[indexDesc.Length];
3034 return array;
3035 }
3036
3037 internal int NewRecord()
3038 {
3039 return NewRecord(-1);
3040 }
3041
3043 {
3045 }
3046
3047 internal int NewRecordFromArray(object[] value)
3048 {
3050 if (count < value.Length)
3051 {
3053 }
3055 try
3056 {
3057 for (int i = 0; i < value.Length; i++)
3058 {
3059 object obj = value[i];
3060 if (obj != null)
3061 {
3063 }
3064 else
3065 {
3066 _columnCollection[i].Init(record);
3067 }
3068 }
3069 for (int j = value.Length; j < count; j++)
3070 {
3071 _columnCollection[j].Init(record);
3072 }
3073 return record;
3074 }
3076 {
3078 throw;
3079 }
3080 }
3081
3082 internal int NewRecord(int sourceRecord)
3083 {
3084 int num = _recordManager.NewRecordBase();
3086 if (-1 == sourceRecord)
3087 {
3088 for (int i = 0; i < count; i++)
3089 {
3090 _columnCollection[i].Init(num);
3091 }
3092 }
3093 else
3094 {
3095 for (int j = 0; j < count; j++)
3096 {
3097 _columnCollection[j].Copy(sourceRecord, num);
3098 }
3099 }
3100 return num;
3101 }
3102
3110
3112 {
3114 }
3115
3117 {
3118 DataRow dataRow = NewRow(-1);
3120 return dataRow;
3121 }
3122
3124 {
3126 foreach (DataColumn column in Columns)
3127 {
3129 {
3130 continue;
3131 }
3132 if (!column.AutoIncrement)
3133 {
3134 if (column.AllowDBNull)
3135 {
3137 }
3138 else if (column.DefaultValue != null)
3139 {
3140 dataRow[column] = column.DefaultValue;
3141 }
3142 }
3143 else
3144 {
3145 column.Init(dataRow._tempRecord);
3146 }
3147 }
3148 return dataRow;
3149 }
3150
3152 {
3153 if (_onTableNewRowDelegate != null)
3154 {
3156 OnTableNewRow(e);
3157 }
3158 }
3159
3160 internal DataRow NewRow(int record)
3161 {
3162 if (-1 == record)
3163 {
3164 record = NewRecord(-1);
3165 }
3170 return dataRow;
3171 }
3172
3174 {
3175 return new DataRow(builder);
3176 }
3177
3178 protected virtual Type GetRowType()
3179 {
3180 return typeof(DataRow);
3181 }
3182
3183 [MethodImpl(MethodImplOptions.NoInlining)]
3184 protected internal DataRow[] NewRowArray(int size)
3185 {
3186 if (IsTypedDataTable)
3187 {
3188 if (size == 0)
3189 {
3190 if (_emptyDataRowArray == null)
3191 {
3193 }
3194 return _emptyDataRowArray;
3195 }
3196 return (DataRow[])Array.CreateInstance(GetRowType(), size);
3197 }
3198 if (size != 0)
3199 {
3200 return new DataRow[size];
3201 }
3202 return Array.Empty<DataRow>();
3203 }
3204
3205 protected internal virtual void OnColumnChanging(DataColumnChangeEventArgs e)
3206 {
3207 if (_onColumnChangingDelegate != null)
3208 {
3209 DataCommonEventSource.Log.Trace("<ds.DataTable.OnColumnChanging|INFO> {0}", ObjectID);
3211 }
3212 }
3213
3214 protected internal virtual void OnColumnChanged(DataColumnChangeEventArgs e)
3215 {
3216 if (_onColumnChangedDelegate != null)
3217 {
3218 DataCommonEventSource.Log.Trace("<ds.DataTable.OnColumnChanged|INFO> {0}", ObjectID);
3219 _onColumnChangedDelegate(this, e);
3220 }
3221 }
3222
3224 {
3225 if (_onPropertyChangingDelegate != null)
3226 {
3227 DataCommonEventSource.Log.Trace("<ds.DataTable.OnPropertyChanging|INFO> {0}", ObjectID);
3229 }
3230 }
3231
3233 {
3235 }
3236
3237 protected virtual void OnRemoveColumn(DataColumn column)
3238 {
3239 }
3240
3242 {
3244 {
3245 if (args == null)
3246 {
3248 }
3250 }
3251 return args;
3252 }
3253
3255 {
3257 {
3258 if (args == null)
3259 {
3261 }
3263 }
3264 return args;
3265 }
3266
3267 protected virtual void OnRowChanged(DataRowChangeEventArgs e)
3268 {
3269 if (_onRowChangedDelegate != null)
3270 {
3271 DataCommonEventSource.Log.Trace("<ds.DataTable.OnRowChanged|INFO> {0}", ObjectID);
3272 _onRowChangedDelegate(this, e);
3273 }
3274 }
3275
3276 protected virtual void OnRowChanging(DataRowChangeEventArgs e)
3277 {
3278 if (_onRowChangingDelegate != null)
3279 {
3280 DataCommonEventSource.Log.Trace("<ds.DataTable.OnRowChanging|INFO> {0}", ObjectID);
3281 _onRowChangingDelegate(this, e);
3282 }
3283 }
3284
3285 protected virtual void OnRowDeleting(DataRowChangeEventArgs e)
3286 {
3287 if (_onRowDeletingDelegate != null)
3288 {
3289 DataCommonEventSource.Log.Trace("<ds.DataTable.OnRowDeleting|INFO> {0}", ObjectID);
3290 _onRowDeletingDelegate(this, e);
3291 }
3292 }
3293
3294 protected virtual void OnRowDeleted(DataRowChangeEventArgs e)
3295 {
3296 if (_onRowDeletedDelegate != null)
3297 {
3298 DataCommonEventSource.Log.Trace("<ds.DataTable.OnRowDeleted|INFO> {0}", ObjectID);
3299 _onRowDeletedDelegate(this, e);
3300 }
3301 }
3302
3303 protected virtual void OnTableCleared(DataTableClearEventArgs e)
3304 {
3305 if (_onTableClearedDelegate != null)
3306 {
3307 DataCommonEventSource.Log.Trace("<ds.DataTable.OnTableCleared|INFO> {0}", ObjectID);
3308 _onTableClearedDelegate(this, e);
3309 }
3310 }
3311
3313 {
3314 if (_onTableClearingDelegate != null)
3315 {
3316 DataCommonEventSource.Log.Trace("<ds.DataTable.OnTableClearing|INFO> {0}", ObjectID);
3317 _onTableClearingDelegate(this, e);
3318 }
3319 }
3320
3321 protected virtual void OnTableNewRow(DataTableNewRowEventArgs e)
3322 {
3323 if (_onTableNewRowDelegate != null)
3324 {
3325 DataCommonEventSource.Log.Trace("<ds.DataTable.OnTableNewRow|INFO> {0}", ObjectID);
3326 _onTableNewRowDelegate(this, e);
3327 }
3328 }
3329
3330 private void OnInitialized()
3331 {
3332 if (_onInitialized != null)
3333 {
3334 DataCommonEventSource.Log.Trace("<ds.DataTable.OnInitialized|INFO> {0}", ObjectID);
3336 }
3337 }
3338
3340 {
3341 IndexField[] array = Array.Empty<IndexField>();
3342 if (sortString != null && 0 < sortString.Length)
3343 {
3344 string[] array2 = sortString.Split(',', StringSplitOptions.TrimEntries);
3345 array = new IndexField[array2.Length];
3346 for (int i = 0; i < array2.Length; i++)
3347 {
3348 string text = array2[i];
3349 int length = text.Length;
3350 bool isDescending = false;
3351 if (length >= 5 && string.Compare(text, length - 4, " ASC", 0, 4, StringComparison.OrdinalIgnoreCase) == 0)
3352 {
3353 text = text.AsSpan(0, length - 4).Trim().ToString();
3354 }
3355 else if (length >= 6 && string.Compare(text, length - 5, " DESC", 0, 5, StringComparison.OrdinalIgnoreCase) == 0)
3356 {
3357 isDescending = true;
3358 text = text.AsSpan(0, length - 5).Trim().ToString();
3359 }
3360 if (text.StartsWith('['))
3361 {
3362 if (!text.EndsWith(']'))
3363 {
3365 }
3366 text = text.Substring(1, text.Length - 2);
3367 }
3369 if (dataColumn == null)
3370 {
3372 }
3374 }
3375 }
3376 return array;
3377 }
3378
3379 internal void RaisePropertyChanging(string name)
3380 {
3382 }
3383
3384 internal void RecordChanged(int record)
3385 {
3387 try
3388 {
3390 for (int i = 0; i < count; i++)
3391 {
3393 if (0 < index.RefCount)
3394 {
3395 index.RecordChanged(record);
3396 }
3397 }
3398 }
3399 finally
3400 {
3402 }
3403 }
3404
3405 internal void RecordChanged(int[] oldIndex, int[] newIndex)
3406 {
3408 try
3409 {
3411 for (int i = 0; i < count; i++)
3412 {
3414 if (0 < index.RefCount)
3415 {
3416 index.RecordChanged(oldIndex[i], newIndex[i]);
3417 }
3418 }
3419 }
3420 finally
3421 {
3423 }
3424 }
3425
3427 {
3429 try
3430 {
3432 for (int i = 0; i < count; i++)
3433 {
3435 if (0 < index.RefCount)
3436 {
3437 index.RecordStateChanged(record, oldState, newState);
3438 }
3439 }
3440 }
3441 finally
3442 {
3444 }
3445 }
3446
3448 {
3450 try
3451 {
3453 for (int i = 0; i < count; i++)
3454 {
3456 if (0 < index.RefCount)
3457 {
3458 if (record1 != -1 && record2 != -1)
3459 {
3460 index.RecordStateChanged(record1, oldState1, newState1, record2, oldState2, newState2);
3461 }
3462 else if (record1 != -1)
3463 {
3464 index.RecordStateChanged(record1, oldState1, newState1);
3465 }
3466 else if (record2 != -1)
3467 {
3468 index.RecordStateChanged(record2, oldState2, newState2);
3469 }
3470 }
3471 }
3472 }
3473 finally
3474 {
3476 }
3477 }
3478
3480 {
3481 int num = LiveIndexes.Count;
3482 int[] array = new int[num];
3483 int recordFromVersion = row.GetRecordFromVersion(version);
3485 while (--num >= 0)
3486 {
3487 if (row.HasVersion(version) && (recordState & _indexes[num].RecordStates) != 0)
3488 {
3489 int index = _indexes[num].GetIndex(recordFromVersion);
3490 if (index > -1)
3491 {
3492 array[num] = index;
3493 _indexes[num].DeleteRecordFromIndex(index);
3494 }
3495 else
3496 {
3497 array[num] = -1;
3498 }
3499 }
3500 else
3501 {
3502 array[num] = -1;
3503 }
3504 }
3505 return array;
3506 }
3507
3509 {
3510 int num = LiveIndexes.Count;
3511 int[] array = new int[num];
3512 int recordFromVersion = row.GetRecordFromVersion(version);
3514 while (--num >= 0)
3515 {
3516 if (row.HasVersion(version))
3517 {
3518 if ((recordState & _indexes[num].RecordStates) != 0)
3519 {
3520 array[num] = _indexes[num].InsertRecordToIndex(recordFromVersion);
3521 }
3522 else
3523 {
3524 array[num] = -1;
3525 }
3526 }
3527 }
3528 return array;
3529 }
3530
3532 {
3533 int recordFromVersion = dr.GetRecordFromVersion(version);
3534 bool flag = false;
3535 if ((DataStorage.IsTypeCustomType(dc.DataType) && newValue != dc[recordFromVersion]) || !dc.CompareValueTo(recordFromVersion, newValue, checkType: true))
3536 {
3537 int[] oldIndex = dr.Table.RemoveRecordFromIndexes(dr, version);
3538 dc.SetValue(recordFromVersion, newValue);
3539 int[] newIndex = dr.Table.InsertRecordToIndexes(dr, version);
3540 if (dr.HasVersion(version))
3541 {
3542 if (version != DataRowVersion.Original)
3543 {
3544 dr.Table.RecordChanged(oldIndex, newIndex);
3545 }
3546 if (dc._dependentColumns != null)
3547 {
3548 dc.Table.EvaluateDependentExpressions(dc._dependentColumns, dr, version, null);
3549 }
3550 }
3551 }
3552 dr.ResetLastChangedColumn();
3553 }
3554
3555 public void RejectChanges()
3556 {
3557 long scopeId = DataCommonEventSource.Log.EnterScope("<ds.DataTable.RejectChanges|API> {0}", ObjectID);
3558 try
3559 {
3560 DataRow[] array = new DataRow[Rows.Count];
3561 Rows.CopyTo(array, 0);
3562 for (int i = 0; i < array.Length; i++)
3563 {
3564 RollbackRow(array[i]);
3565 }
3566 }
3567 finally
3568 {
3569 DataCommonEventSource.Log.ExitScope(scopeId);
3570 }
3571 }
3572
3573 internal void RemoveRow(DataRow row, bool check)
3574 {
3575 if (row.rowID == -1)
3576 {
3578 }
3579 if (check && _dataSet != null)
3580 {
3582 while (parentForeignKeyConstraintEnumerator.GetNext())
3583 {
3584 parentForeignKeyConstraintEnumerator.GetForeignKeyConstraint().CheckCanRemoveParentRow(row);
3585 }
3586 }
3587 int record = row._oldRecord;
3588 int record2 = row._newRecord;
3589 DataViewRowState recordState = row.GetRecordState(record);
3590 DataViewRowState recordState2 = row.GetRecordState(record2);
3591 row._oldRecord = -1;
3592 row._newRecord = -1;
3593 if (record == record2)
3594 {
3595 record = -1;
3596 }
3600 row.rowID = -1L;
3602 }
3603
3604 public virtual void Reset()
3605 {
3606 long scopeId = DataCommonEventSource.Log.EnterScope("<ds.DataTable.Reset|API> {0}", ObjectID);
3607 try
3608 {
3609 Clear();
3612 int num = parentRelations.Count;
3613 while (num > 0)
3614 {
3615 num--;
3616 parentRelations.RemoveAt(num);
3617 }
3619 num = parentRelations.Count;
3620 while (num > 0)
3621 {
3622 num--;
3623 parentRelations.RemoveAt(num);
3624 }
3625 Columns.Clear();
3626 _indexes.Clear();
3627 }
3628 finally
3629 {
3630 DataCommonEventSource.Log.ExitScope(scopeId);
3631 }
3632 }
3633
3634 internal void ResetIndexes()
3635 {
3637 }
3638
3640 {
3642 try
3643 {
3645 for (int i = 0; i < count; i++)
3646 {
3648 if (0 >= index.RefCount)
3649 {
3650 continue;
3651 }
3652 if (column == null)
3653 {
3654 index.Reset();
3655 continue;
3656 }
3657 bool flag = false;
3658 IndexField[] indexFields = index._indexFields;
3659 for (int j = 0; j < indexFields.Length; j++)
3660 {
3662 if (column == indexField.Column)
3663 {
3664 flag = true;
3665 break;
3666 }
3667 }
3668 if (flag)
3669 {
3670 index.Reset();
3671 }
3672 }
3673 }
3674 finally
3675 {
3677 }
3678 }
3679
3680 internal void RollbackRow(DataRow row)
3681 {
3682 row.CancelEdit();
3683 SetNewRecord(row, row._oldRecord, DataRowAction.Rollback);
3684 }
3685
3687 {
3688 try
3689 {
3691 {
3693 }
3694 else if (DataRowAction.Delete == eAction && eRow._newRecord == -1 && (IsTypedDataTable || _onRowDeletedDelegate != null))
3695 {
3696 if (args == null)
3697 {
3699 }
3701 }
3702 }
3704 {
3706 }
3707 return args;
3708 }
3709
3711 {
3713 {
3714 eRow._inChangingEvent = true;
3715 try
3716 {
3718 }
3719 finally
3720 {
3721 eRow._inChangingEvent = false;
3722 }
3723 }
3724 else if (DataRowAction.Delete == eAction && eRow._newRecord != -1 && (IsTypedDataTable || _onRowDeletingDelegate != null))
3725 {
3726 eRow._inDeletingEvent = true;
3727 try
3728 {
3729 if (args == null)
3730 {
3732 }
3734 }
3735 finally
3736 {
3737 eRow._inDeletingEvent = false;
3738 }
3739 }
3740 return args;
3741 }
3742
3744 {
3746 {
3748 for (int i = 0; i < count; i++)
3749 {
3751 if (!dataColumn.Computed || eAction != DataRowAction.Add)
3752 {
3753 dataColumn.CheckColumnConstraint(eRow, eAction);
3754 }
3755 }
3757 for (int j = 0; j < count2; j++)
3758 {
3759 _constraintCollection[j].CheckConstraint(eRow, eAction);
3760 }
3761 }
3762 if (fireEvent)
3763 {
3765 }
3766 if (!_inDataLoad && !MergingData && eAction != 0 && eAction != DataRowAction.ChangeOriginal)
3767 {
3769 }
3770 return args;
3771 }
3772
3773 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "Filter expression is empty therefore this is safe.")]
3774 public DataRow[] Select()
3775 {
3776 DataCommonEventSource.Log.Trace("<ds.DataTable.Select|API> {0}", ObjectID);
3777 return new Select(this, "", "", DataViewRowState.CurrentRows).SelectRows();
3778 }
3779
3780 [RequiresUnreferencedCode("Members of types used in the filter expression might be trimmed.")]
3782 {
3783 DataCommonEventSource.Log.Trace("<ds.DataTable.Select|API> {0}, filterExpression='{1}'", ObjectID, filterExpression);
3784 return new Select(this, filterExpression, "", DataViewRowState.CurrentRows).SelectRows();
3785 }
3786
3787 [RequiresUnreferencedCode("Members of types used in the filter expression might be trimmed.")]
3788 public DataRow[] Select(string? filterExpression, string? sort)
3789 {
3790 DataCommonEventSource.Log.Trace("<ds.DataTable.Select|API> {0}, filterExpression='{1}', sort='{2}'", ObjectID, filterExpression, sort);
3791 return new Select(this, filterExpression, sort, DataViewRowState.CurrentRows).SelectRows();
3792 }
3793
3794 [RequiresUnreferencedCode("Members of types used in the filter expression might be trimmed.")]
3796 {
3797 DataCommonEventSource.Log.Trace("<ds.DataTable.Select|API> {0}, filterExpression='{1}', sort='{2}', recordStates={3}", ObjectID, filterExpression, sort, recordStates);
3798 return new Select(this, filterExpression, sort, recordStates).SelectRows();
3799 }
3800
3810
3812 {
3813 deferredException = null;
3814 if (row._tempRecord != proposedRecord)
3815 {
3816 if (!_inDataLoad)
3817 {
3818 row.CheckInTable();
3820 }
3821 if (proposedRecord == row._newRecord)
3822 {
3823 if (isInMerge)
3824 {
3825 RaiseRowChanged(null, row, action);
3826 }
3827 return;
3828 }
3830 }
3832 try
3833 {
3836 }
3837 catch
3838 {
3839 row._tempRecord = -1;
3840 throw;
3841 }
3842 finally
3843 {
3844 row._action = DataRowAction.Nothing;
3845 }
3846 row._tempRecord = -1;
3847 int record = row._newRecord;
3848 int num = ((proposedRecord != -1) ? proposedRecord : ((row.RowState != DataRowState.Unchanged) ? row._oldRecord : (-1)));
3849 if (action == DataRowAction.Add)
3850 {
3851 if (position == -1)
3852 {
3853 Rows.ArrayAdd(row);
3854 }
3855 else
3856 {
3857 Rows.ArrayInsert(row, position);
3858 }
3859 }
3860 List<DataRow> list = null;
3861 if ((action == DataRowAction.Delete || action == DataRowAction.Change) && _dependentColumns != null && _dependentColumns.Count > 0)
3862 {
3863 list = new List<DataRow>();
3864 for (int i = 0; i < ParentRelations.Count; i++)
3865 {
3867 if (dataRelation.ChildTable == row.Table)
3868 {
3869 list.InsertRange(list.Count, row.GetParentRows(dataRelation));
3870 }
3871 }
3872 for (int j = 0; j < ChildRelations.Count; j++)
3873 {
3875 if (dataRelation2.ParentTable == row.Table)
3876 {
3877 list.InsertRange(list.Count, row.GetChildRows(dataRelation2));
3878 }
3879 }
3880 }
3881 if (!suppressEnsurePropertyChanged && !row.HasPropertyChanged && row._newRecord != proposedRecord && -1 != proposedRecord && -1 != row._newRecord)
3882 {
3883 row.LastChangedColumn = null;
3884 row.LastChangedColumn = null;
3885 }
3886 if (LiveIndexes.Count != 0)
3887 {
3888 if (-1 == record && -1 != proposedRecord && -1 != row._oldRecord && proposedRecord != row._oldRecord)
3889 {
3890 record = row._oldRecord;
3891 }
3892 DataViewRowState recordState = row.GetRecordState(record);
3893 DataViewRowState recordState2 = row.GetRecordState(num);
3895 if (proposedRecord != -1)
3896 {
3898 }
3899 DataViewRowState recordState3 = row.GetRecordState(record);
3900 DataViewRowState recordState4 = row.GetRecordState(num);
3902 }
3903 else
3904 {
3906 if (proposedRecord != -1)
3907 {
3909 }
3910 }
3911 row.ResetLastChangedColumn();
3912 if (-1 != record && record != row._oldRecord && record != row._tempRecord && record != row._newRecord && row == _recordManager[record])
3913 {
3915 }
3916 if (row.RowState == DataRowState.Detached && row.rowID != -1)
3917 {
3918 RemoveRow(row, check: false);
3919 }
3920 if (_dependentColumns != null && _dependentColumns.Count > 0)
3921 {
3922 try
3923 {
3925 }
3926 catch (Exception ex)
3927 {
3928 if (action != DataRowAction.Add)
3929 {
3930 throw;
3931 }
3933 }
3934 }
3935 try
3936 {
3937 if (fireEvent)
3938 {
3940 }
3941 }
3943 {
3945 }
3946 }
3947
3949 {
3950 if (!_inDataLoad)
3951 {
3952 row.CheckInTable();
3954 }
3955 if (proposedRecord == row._oldRecord)
3956 {
3957 return;
3958 }
3959 int record = row._oldRecord;
3960 try
3961 {
3962 if (LiveIndexes.Count != 0)
3963 {
3964 if (-1 == record && -1 != proposedRecord && -1 != row._newRecord && proposedRecord != row._newRecord)
3965 {
3966 record = row._newRecord;
3967 }
3968 DataViewRowState recordState = row.GetRecordState(record);
3971 if (proposedRecord != -1)
3972 {
3974 }
3975 DataViewRowState recordState3 = row.GetRecordState(record);
3978 }
3979 else
3980 {
3982 if (proposedRecord != -1)
3983 {
3985 }
3986 }
3987 }
3988 finally
3989 {
3990 if (record != -1 && record != row._tempRecord && record != row._oldRecord && record != row._newRecord)
3991 {
3993 }
3994 if (row.RowState == DataRowState.Detached && row.rowID != -1)
3995 {
3996 RemoveRow(row, check: false);
3997 }
3998 }
3999 }
4000
4002 {
4003 _shadowCount--;
4004 if (_shadowCount == 0)
4005 {
4006 _shadowIndexes = null;
4007 }
4008 }
4009
4010 private void SetShadowIndexes()
4011 {
4012 if (_shadowIndexes == null)
4013 {
4015 _shadowCount = 1;
4016 }
4017 else
4018 {
4019 _shadowCount++;
4020 }
4021 }
4022
4023 internal void ShadowIndexCopy()
4024 {
4025 if (_shadowIndexes == _indexes)
4026 {
4028 }
4029 }
4030
4031 public override string ToString()
4032 {
4033 if (_displayExpression != null)
4034 {
4035 return TableName + " + " + DisplayExpressionInternal;
4036 }
4037 return TableName;
4038 }
4039
4040 public void BeginLoadData()
4041 {
4042 long scopeId = DataCommonEventSource.Log.EnterScope("<ds.DataTable.BeginLoadData|API> {0}", ObjectID);
4043 try
4044 {
4045 if (_inDataLoad)
4046 {
4047 return;
4048 }
4049 _inDataLoad = true;
4050 _loadIndex = null;
4051 _initialLoad = Rows.Count == 0;
4052 if (_initialLoad)
4053 {
4055 }
4056 else
4057 {
4058 if (_primaryKey != null)
4059 {
4061 }
4062 if (_loadIndex != null)
4063 {
4065 }
4066 }
4067 if (DataSet != null)
4068 {
4071 }
4072 else
4073 {
4074 EnforceConstraints = false;
4075 }
4076 }
4077 finally
4078 {
4079 DataCommonEventSource.Log.ExitScope(scopeId);
4080 }
4081 }
4082
4083 public void EndLoadData()
4084 {
4085 long scopeId = DataCommonEventSource.Log.EnterScope("<ds.DataTable.EndLoadData|API> {0}", ObjectID);
4086 try
4087 {
4088 if (_inDataLoad)
4089 {
4090 if (_loadIndex != null)
4091 {
4093 }
4094 if (_loadIndexwithOriginalAdded != null)
4095 {
4097 }
4098 if (_loadIndexwithCurrentDeleted != null)
4099 {
4101 }
4102 _loadIndex = null;
4105 _inDataLoad = false;
4107 if (DataSet != null)
4108 {
4110 }
4111 else
4112 {
4113 EnforceConstraints = true;
4114 }
4115 }
4116 }
4117 finally
4118 {
4119 DataCommonEventSource.Log.ExitScope(scopeId);
4120 }
4121 }
4122
4124 {
4125 long scopeId = DataCommonEventSource.Log.EnterScope("<ds.DataTable.LoadDataRow|API> {0}, fAcceptChanges={1}", ObjectID, fAcceptChanges);
4126 try
4127 {
4129 if (_inDataLoad)
4130 {
4131 int num = NewRecordFromArray(values);
4132 if (_loadIndex != null)
4133 {
4134 int num2 = _loadIndex.FindRecord(num);
4135 if (num2 != -1)
4136 {
4139 dataRow.CancelEdit();
4140 if (dataRow.RowState == DataRowState.Deleted)
4141 {
4142 SetNewRecord(dataRow, dataRow._oldRecord, DataRowAction.Rollback);
4143 }
4144 SetNewRecord(dataRow, num);
4145 if (fAcceptChanges)
4146 {
4147 dataRow.AcceptChanges();
4148 }
4149 return dataRow;
4150 }
4151 }
4152 dataRow = NewRow(num);
4153 AddRow(dataRow);
4154 if (fAcceptChanges)
4155 {
4156 dataRow.AcceptChanges();
4157 }
4158 return dataRow;
4159 }
4161 if (fAcceptChanges)
4162 {
4163 dataRow.AcceptChanges();
4164 }
4165 return dataRow;
4166 }
4167 finally
4168 {
4169 DataCommonEventSource.Log.ExitScope(scopeId);
4170 }
4171 }
4172
4174 {
4175 long scopeId = DataCommonEventSource.Log.EnterScope("<ds.DataTable.LoadDataRow|API> {0}, loadOption={1}", ObjectID, loadOption);
4176 try
4177 {
4178 Index searchIndex = null;
4179 if (_primaryKey != null)
4180 {
4181 if (loadOption == LoadOption.Upsert)
4182 {
4183 if (_loadIndexwithCurrentDeleted == null)
4184 {
4186 if (_loadIndexwithCurrentDeleted != null)
4187 {
4189 }
4190 }
4192 }
4193 else
4194 {
4195 if (_loadIndexwithOriginalAdded == null)
4196 {
4198 if (_loadIndexwithOriginalAdded != null)
4199 {
4201 }
4202 }
4204 }
4205 }
4207 {
4209 }
4211 }
4212 finally
4213 {
4214 DataCommonEventSource.Log.ExitScope(scopeId);
4215 }
4216 }
4217
4218 internal DataRow UpdatingAdd(object[] values)
4219 {
4220 Index index = null;
4221 if (_primaryKey != null)
4222 {
4224 }
4225 if (index != null)
4226 {
4227 int num = NewRecordFromArray(values);
4228 int num2 = index.FindRecord(num);
4229 if (num2 != -1)
4230 {
4231 int record = index.GetRecord(num2);
4233 dataRow.RejectChanges();
4234 SetNewRecord(dataRow, num);
4235 return dataRow;
4236 }
4237 DataRow dataRow2 = NewRow(num);
4238 Rows.Add(dataRow2);
4239 return dataRow2;
4240 }
4241 return Rows.Add(values);
4242 }
4243
4245 {
4246 if (action != DataRowAction.Add && action != DataRowAction.Change && action != DataRowAction.Rollback && action != DataRowAction.ChangeOriginal)
4247 {
4248 return action == DataRowAction.ChangeCurrentAndOriginal;
4249 }
4250 return true;
4251 }
4252
4253 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "DataColumn with null expression and int data type is safe.")]
4254 internal DataColumn AddUniqueKey(int position)
4255 {
4256 if (_colUnique != null)
4257 {
4258 return _colUnique;
4259 }
4261 if (primaryKey.Length == 1)
4262 {
4263 return primaryKey[0];
4264 }
4265 string columnName = XMLSchema.GenUniqueColumnName(TableName + "_Id", this);
4266 DataColumn dataColumn = new DataColumn(columnName, typeof(int), null, MappingType.Hidden);
4269 dataColumn.AllowDBNull = false;
4270 dataColumn.Unique = true;
4271 if (position == -1)
4272 {
4274 }
4275 else
4276 {
4277 for (int num = Columns.Count - 1; num >= position; num--)
4278 {
4279 Columns[num].SetOrdinalInternal(num + 1);
4280 }
4281 Columns.AddAt(position, dataColumn);
4282 dataColumn.SetOrdinalInternal(position);
4283 }
4284 if (primaryKey.Length == 0)
4285 {
4286 PrimaryKey = new DataColumn[1] { dataColumn };
4287 }
4289 return _colUnique;
4290 }
4291
4293 {
4294 return AddUniqueKey(-1);
4295 }
4296
4297 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "Expression is null and potential problem with data type has already been reported when constructing parentKey")]
4299 {
4300 string columnName = XMLSchema.GenUniqueColumnName(parentKey.ColumnName, this);
4301 DataColumn dataColumn = new DataColumn(columnName, parentKey.DataType, null, MappingType.Hidden);
4303 return dataColumn;
4304 }
4305
4310
4312 {
4314 {
4315 int count = Columns.Count;
4318 for (int i = 0; i < count; i++)
4319 {
4321 }
4322 for (int j = 0; j < count2; j++)
4323 {
4325 }
4327 }
4329 }
4330
4331 public void Merge(DataTable table)
4332 {
4333 Merge(table, preserveChanges: false, MissingSchemaAction.Add);
4334 }
4335
4336 public void Merge(DataTable table, bool preserveChanges)
4337 {
4339 }
4340
4342 {
4343 long scopeId = DataCommonEventSource.Log.EnterScope("<ds.DataTable.Merge|API> {0}, table={1}, preserveChanges={2}, missingSchemaAction={3}", ObjectID, table?.ObjectID ?? 0, preserveChanges, missingSchemaAction);
4344 try
4345 {
4346 if (table == null)
4347 {
4348 throw ExceptionBuilder.ArgumentNull("table");
4349 }
4350 if ((uint)(missingSchemaAction - 1) <= 3u)
4351 {
4353 merger.MergeTable(table);
4354 return;
4355 }
4357 }
4358 finally
4359 {
4360 DataCommonEventSource.Log.ExitScope(scopeId);
4361 }
4362 }
4363
4364 [RequiresUnreferencedCode("Members from types used in the expression column to be trimmed if not referenced directly.")]
4365 public void Load(IDataReader reader)
4366 {
4367 Load(reader, LoadOption.PreserveChanges, null);
4368 }
4369
4370 [RequiresUnreferencedCode("Using LoadOption may cause members from types used in the expression column to be trimmed if not referenced directly.")]
4372 {
4373 Load(reader, loadOption, null);
4374 }
4375
4376 [RequiresUnreferencedCode("Using LoadOption may cause members from types used in the expression column to be trimmed if not referenced directly.")]
4378 {
4379 long scopeId = DataCommonEventSource.Log.EnterScope("<ds.DataTable.Load|API> {0}, loadOption={1}", ObjectID, loadOption);
4380 try
4381 {
4382 if (PrimaryKey.Length != 0 || !(reader is DataTableReader dataTableReader) || dataTableReader.CurrentDataTable != this)
4383 {
4387 if (errorHandler != null)
4388 {
4390 }
4391 loadAdapter.FillFromReader(new DataTable[1] { this }, reader, 0, 0);
4392 if (!reader.IsClosed && !reader.NextResult())
4393 {
4394 reader.Close();
4395 }
4396 }
4397 }
4398 finally
4399 {
4400 DataCommonEventSource.Log.ExitScope(scopeId);
4401 }
4402 }
4403
4405 {
4406 DataRow dataRow = null;
4407 int num2;
4408 if (searchIndex != null)
4409 {
4410 int[] array = Array.Empty<int>();
4411 if (_primaryKey != null)
4412 {
4413 array = new int[_primaryKey.ColumnsReference.Length];
4414 for (int i = 0; i < _primaryKey.ColumnsReference.Length; i++)
4415 {
4417 }
4418 }
4419 object[] array2 = new object[array.Length];
4420 for (int j = 0; j < array.Length; j++)
4421 {
4422 array2[j] = values[array[j]];
4423 }
4424 Range range = searchIndex.FindRecords(array2);
4425 if (!range.IsNull)
4426 {
4427 int num = 0;
4428 for (int k = range.Min; k <= range.Max; k++)
4429 {
4430 int record = searchIndex.GetRecord(k);
4433 for (int l = 0; l < values.Length; l++)
4434 {
4435 if (values[l] == null)
4436 {
4438 }
4439 }
4440 for (int m = values.Length; m < _columnCollection.Count; m++)
4441 {
4443 }
4444 if (loadOption != LoadOption.Upsert || dataRow.RowState != DataRowState.Deleted)
4445 {
4447 }
4448 else
4449 {
4450 num++;
4451 }
4452 }
4453 if (num == 0)
4454 {
4455 return dataRow;
4456 }
4457 }
4458 }
4460 dataRow = NewRow(num2);
4463 switch (loadOption)
4464 {
4465 case LoadOption.OverwriteChanges:
4466 case LoadOption.PreserveChanges:
4467 eAction = DataRowAction.ChangeCurrentAndOriginal;
4468 break;
4469 case LoadOption.Upsert:
4471 break;
4472 default:
4473 throw ExceptionBuilder.ArgumentOutOfRange("LoadOption");
4474 }
4476 InsertRow(dataRow, -1L, -1, fireEvent: false);
4477 switch (loadOption)
4478 {
4479 case LoadOption.OverwriteChanges:
4480 case LoadOption.PreserveChanges:
4482 break;
4483 default:
4484 throw ExceptionBuilder.ArgumentOutOfRange("LoadOption");
4485 case LoadOption.Upsert:
4486 break;
4487 }
4489 return dataRow;
4490 }
4491
4493 {
4494 bool flag = false;
4495 if (checkReadOnly)
4496 {
4497 foreach (DataColumn column in Columns)
4498 {
4499 if (!column.ReadOnly || column.Computed)
4500 {
4501 continue;
4502 }
4503 switch (loadOption)
4504 {
4505 case LoadOption.OverwriteChanges:
4507 {
4508 flag = true;
4509 }
4510 break;
4511 case LoadOption.Upsert:
4512 if (dataRow[column, DataRowVersion.Current] != column[recordNo])
4513 {
4514 flag = true;
4515 }
4516 break;
4517 case LoadOption.PreserveChanges:
4518 if (dataRow[column, DataRowVersion.Original] != column[recordNo])
4519 {
4520 flag = true;
4521 }
4522 break;
4523 }
4524 }
4525 }
4528 int record = dataRow._tempRecord;
4530 switch (loadOption)
4531 {
4532 case LoadOption.OverwriteChanges:
4533 dataRowAction = DataRowAction.ChangeCurrentAndOriginal;
4534 break;
4535 case LoadOption.Upsert:
4536 switch (dataRow.RowState)
4537 {
4538 case DataRowState.Unchanged:
4539 foreach (DataColumn column2 in dataRow.Table.Columns)
4540 {
4541 if (column2.Compare(dataRow._newRecord, recordNo) != 0)
4542 {
4544 break;
4545 }
4546 }
4547 break;
4548 default:
4550 break;
4551 case DataRowState.Deleted:
4552 break;
4553 }
4554 break;
4555 case LoadOption.PreserveChanges:
4556 {
4557 DataRowState rowState = dataRow.RowState;
4558 DataRowAction dataRowAction2 = ((rowState != DataRowState.Unchanged) ? DataRowAction.ChangeOriginal : DataRowAction.ChangeCurrentAndOriginal);
4560 break;
4561 }
4562 default:
4563 throw ExceptionBuilder.ArgumentOutOfRange("LoadOption");
4564 }
4565 try
4566 {
4568 if (dataRowAction == DataRowAction.Nothing)
4569 {
4571 try
4572 {
4574 }
4575 finally
4576 {
4578 }
4579 }
4580 }
4581 finally
4582 {
4583 if (DataRowState.Detached == dataRow.RowState)
4584 {
4585 if (-1 != record)
4586 {
4588 }
4589 }
4590 else if (dataRow._tempRecord != recordNo)
4591 {
4592 if (-1 != record)
4593 {
4595 }
4596 if (-1 != recordNo)
4597 {
4599 }
4600 recordNo = dataRow._tempRecord;
4601 }
4602 else
4603 {
4605 }
4606 }
4607 if (dataRow._tempRecord != -1)
4608 {
4609 dataRow.CancelEdit();
4610 }
4611 switch (loadOption)
4612 {
4613 case LoadOption.OverwriteChanges:
4616 break;
4617 case LoadOption.Upsert:
4618 if (dataRow.RowState == DataRowState.Unchanged)
4619 {
4621 if (!dataRow.HasChanges())
4622 {
4624 }
4625 }
4626 else
4627 {
4628 if (dataRow.RowState == DataRowState.Deleted)
4629 {
4630 dataRow.RejectChanges();
4631 }
4633 }
4634 break;
4635 case LoadOption.PreserveChanges:
4636 if (dataRow.RowState == DataRowState.Unchanged)
4637 {
4640 }
4641 else
4642 {
4644 }
4645 break;
4646 default:
4647 throw ExceptionBuilder.ArgumentOutOfRange("LoadOption");
4648 }
4649 if (flag)
4650 {
4652 if (dataRow.RowError.Length == 0)
4653 {
4655 }
4656 else
4657 {
4659 }
4660 foreach (DataColumn column3 in Columns)
4661 {
4662 if (column3.ReadOnly && !column3.Computed)
4663 {
4664 dataRow.SetColumnError(column3, load_ReadOnlyDataModified);
4665 }
4666 }
4667 }
4669 if (dataRowAction == DataRowAction.Nothing)
4670 {
4672 try
4673 {
4675 }
4676 finally
4677 {
4679 }
4680 }
4681 }
4682
4684 {
4685 return new DataTableReader(this);
4686 }
4687
4688 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
4689 public void WriteXml(Stream? stream)
4690 {
4691 WriteXml(stream, XmlWriteMode.IgnoreSchema, writeHierarchy: false);
4692 }
4693
4694 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
4696 {
4698 }
4699
4700 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
4702 {
4703 WriteXml(writer, XmlWriteMode.IgnoreSchema, writeHierarchy: false);
4704 }
4705
4706 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
4708 {
4710 }
4711
4712 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
4714 {
4715 WriteXml(writer, XmlWriteMode.IgnoreSchema, writeHierarchy: false);
4716 }
4717
4718 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
4720 {
4722 }
4723
4724 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
4725 public void WriteXml(string fileName)
4726 {
4727 WriteXml(fileName, XmlWriteMode.IgnoreSchema, writeHierarchy: false);
4728 }
4729
4730 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
4731 public void WriteXml(string fileName, bool writeHierarchy)
4732 {
4734 }
4735
4736 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
4738 {
4739 WriteXml(stream, mode, writeHierarchy: false);
4740 }
4741
4742 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
4744 {
4745 if (stream != null)
4746 {
4750 }
4751 }
4752
4753 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
4755 {
4756 WriteXml(writer, mode, writeHierarchy: false);
4757 }
4758
4759 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
4761 {
4762 if (writer != null)
4763 {
4767 }
4768 }
4769
4770 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
4772 {
4773 WriteXml(writer, mode, writeHierarchy: false);
4774 }
4775
4776 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
4778 {
4779 long scopeId = DataCommonEventSource.Log.EnterScope("<ds.DataTable.WriteXml|API> {0}, mode={1}", ObjectID, mode);
4780 try
4781 {
4782 if (_tableName.Length == 0)
4783 {
4785 }
4786 if (writer == null)
4787 {
4788 return;
4789 }
4790 switch (mode)
4791 {
4792 case XmlWriteMode.DiffGram:
4793 new NewDiffgramGen(this, writeHierarchy).Save(writer, this);
4794 break;
4795 case XmlWriteMode.WriteSchema:
4796 {
4797 DataSet dataSet = null;
4799 if (DataSet == null)
4800 {
4801 dataSet = new DataSet();
4802 dataSet.SetLocaleValue(_culture, _cultureUserSet);
4806 dataSet.Tables.Add(this);
4807 }
4808 if (writer != null)
4809 {
4812 }
4813 if (dataSet != null)
4814 {
4815 dataSet.Tables.Remove(this);
4817 }
4818 break;
4819 }
4820 default:
4821 {
4823 xmlDataTreeWriter.Save(writer, writeSchema: false);
4824 break;
4825 }
4826 }
4827 }
4828 finally
4829 {
4830 DataCommonEventSource.Log.ExitScope(scopeId);
4831 }
4832 }
4833
4834 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
4835 public void WriteXml(string fileName, XmlWriteMode mode)
4836 {
4837 WriteXml(fileName, mode, writeHierarchy: false);
4838 }
4839
4840 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
4841 public void WriteXml(string fileName, XmlWriteMode mode, bool writeHierarchy)
4842 {
4843 long scopeId = DataCommonEventSource.Log.EnterScope("<ds.DataTable.WriteXml|API> {0}, fileName='{1}', mode={2}", ObjectID, fileName, mode);
4844 try
4845 {
4848 xmlTextWriter.WriteStartDocument(standalone: true);
4850 xmlTextWriter.WriteEndDocument();
4851 }
4852 finally
4853 {
4854 DataCommonEventSource.Log.ExitScope(scopeId);
4855 }
4856 }
4857
4858 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
4860 {
4862 }
4863
4864 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
4866 {
4867 if (stream != null)
4868 {
4872 }
4873 }
4874
4875 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
4877 {
4879 }
4880
4881 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
4883 {
4884 if (writer != null)
4885 {
4889 }
4890 }
4891
4893 {
4895 list.Add(dt);
4896 if (writeHierarchy)
4897 {
4899 }
4901 }
4902
4904 {
4905 foreach (DataTable table in tableList)
4906 {
4907 foreach (DataColumn column in table.Columns)
4908 {
4909 if (column.Expression.Length == 0)
4910 {
4911 continue;
4912 }
4913 DataColumn[] dependency = column.DataExpression.GetDependency();
4914 for (int i = 0; i < dependency.Length; i++)
4915 {
4916 if (!tableList.Contains(dependency[i].Table))
4917 {
4918 return false;
4919 }
4920 }
4921 }
4922 }
4923 return true;
4924 }
4925
4926 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
4928 {
4930 }
4931
4932 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
4934 {
4935 long scopeId = DataCommonEventSource.Log.EnterScope("<ds.DataTable.WriteXmlSchema|API> {0}", ObjectID);
4936 try
4937 {
4938 if (_tableName.Length == 0)
4939 {
4941 }
4943 {
4945 }
4946 DataSet dataSet = null;
4948 if (DataSet == null)
4949 {
4950 dataSet = new DataSet();
4951 dataSet.SetLocaleValue(_culture, _cultureUserSet);
4955 dataSet.Tables.Add(this);
4956 }
4957 if (writer != null)
4958 {
4960 xmlTreeGen.Save(null, this, writer, writeHierarchy);
4961 }
4962 if (dataSet != null)
4963 {
4964 dataSet.Tables.Remove(this);
4966 }
4967 }
4968 finally
4969 {
4970 DataCommonEventSource.Log.ExitScope(scopeId);
4971 }
4972 }
4973
4974 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
4975 public void WriteXmlSchema(string fileName)
4976 {
4978 }
4979
4980 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
4981 public void WriteXmlSchema(string fileName, bool writeHierarchy)
4982 {
4984 try
4985 {
4987 xmlTextWriter.WriteStartDocument(standalone: true);
4989 xmlTextWriter.WriteEndDocument();
4990 }
4991 finally
4992 {
4993 xmlTextWriter.Close();
4994 }
4995 }
4996
4997 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
4999 {
5000 if (stream == null)
5001 {
5002 return XmlReadMode.Auto;
5003 }
5006 return ReadXml(xmlTextReader, denyResolving: false);
5007 }
5008
5009 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
5011 {
5012 if (reader == null)
5013 {
5014 return XmlReadMode.Auto;
5015 }
5018 return ReadXml(xmlTextReader, denyResolving: false);
5019 }
5020
5021 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
5023 {
5026 try
5027 {
5028 return ReadXml(xmlTextReader, denyResolving: false);
5029 }
5030 finally
5031 {
5032 xmlTextReader.Close();
5033 }
5034 }
5035
5036 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
5038 {
5039 return ReadXml(reader, denyResolving: false);
5040 }
5041
5043 {
5044 if (DataSet != null)
5045 {
5047 }
5048 else
5049 {
5051 }
5052 }
5053
5054 private bool IsEmptyXml(XmlReader reader)
5055 {
5056 if (reader.IsEmptyElement)
5057 {
5058 if (reader.AttributeCount == 0 || (reader.LocalName == "diffgram" && reader.NamespaceURI == "urn:schemas-microsoft-com:xml-diffgram-v1"))
5059 {
5060 return true;
5061 }
5062 if (reader.AttributeCount == 1)
5063 {
5064 reader.MoveToAttribute(0);
5065 if (Namespace == reader.Value && Prefix == reader.LocalName && reader.Prefix == "xmlns" && reader.NamespaceURI == "http://www.w3.org/2000/xmlns/")
5066 {
5067 return true;
5068 }
5069 }
5070 }
5071 return false;
5072 }
5073
5074 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
5076 {
5077 IDisposable disposable = null;
5078 long scopeId = DataCommonEventSource.Log.EnterScope("<ds.DataTable.ReadXml|INFO> {0}, denyResolving={1}", ObjectID, denyResolving);
5079 try
5080 {
5083 try
5084 {
5085 bool flag = false;
5086 bool flag2 = false;
5087 bool flag3 = false;
5088 bool isXdr = false;
5089 int num = -1;
5090 XmlReadMode result = XmlReadMode.Auto;
5091 rowDiffIdUsageSection.Prepare(this);
5092 if (reader == null)
5093 {
5094 return result;
5095 }
5096 bool flag4 = false;
5097 if (DataSet != null)
5098 {
5101 }
5102 else
5103 {
5105 EnforceConstraints = false;
5106 }
5107 if (reader is XmlTextReader)
5108 {
5109 ((XmlTextReader)reader).WhitespaceHandling = WhitespaceHandling.Significant;
5110 }
5113 reader.MoveToContent();
5114 if (Columns.Count == 0 && IsEmptyXml(reader))
5115 {
5116 reader.Read();
5117 return result;
5118 }
5119 if (reader.NodeType == XmlNodeType.Element)
5120 {
5121 num = reader.Depth;
5122 if (reader.LocalName == "diffgram" && reader.NamespaceURI == "urn:schemas-microsoft-com:xml-diffgram-v1")
5123 {
5124 if (Columns.Count == 0)
5125 {
5126 if (reader.IsEmptyElement)
5127 {
5128 reader.Read();
5129 return XmlReadMode.DiffGram;
5130 }
5132 }
5133 ReadXmlDiffgram(reader);
5134 ReadEndElement(reader);
5136 return XmlReadMode.DiffGram;
5137 }
5138 if (reader.LocalName == "Schema" && reader.NamespaceURI == "urn:schemas-microsoft-com:xml-data")
5139 {
5140 ReadXDRSchema(reader);
5142 return XmlReadMode.ReadSchema;
5143 }
5144 if (reader.LocalName == "schema" && reader.NamespaceURI == "http://www.w3.org/2001/XMLSchema")
5145 {
5148 return XmlReadMode.ReadSchema;
5149 }
5150 if (reader.LocalName == "schema" && reader.NamespaceURI.StartsWith("http://www.w3.org/", StringComparison.Ordinal))
5151 {
5152 if (DataSet != null)
5153 {
5155 }
5156 else
5157 {
5159 }
5160 throw ExceptionBuilder.DataSetUnsupportedSchema("http://www.w3.org/2001/XMLSchema");
5161 }
5162 XmlElement xmlElement = xmlDocument.CreateElement(reader.Prefix, reader.LocalName, reader.NamespaceURI);
5163 if (reader.HasAttributes)
5164 {
5165 int attributeCount = reader.AttributeCount;
5166 for (int i = 0; i < attributeCount; i++)
5167 {
5168 reader.MoveToAttribute(i);
5169 if (reader.NamespaceURI.Equals("http://www.w3.org/2000/xmlns/"))
5170 {
5171 xmlElement.SetAttribute(reader.Name, reader.GetAttribute(i));
5172 continue;
5173 }
5174 XmlAttribute xmlAttribute = xmlElement.SetAttributeNode(reader.LocalName, reader.NamespaceURI);
5175 xmlAttribute.Prefix = reader.Prefix;
5176 xmlAttribute.Value = reader.GetAttribute(i);
5177 }
5178 }
5179 reader.Read();
5180 while (MoveToElement(reader, num))
5181 {
5182 if (reader.LocalName == "diffgram" && reader.NamespaceURI == "urn:schemas-microsoft-com:xml-diffgram-v1")
5183 {
5184 ReadXmlDiffgram(reader);
5185 ReadEndElement(reader);
5187 return XmlReadMode.DiffGram;
5188 }
5189 if (!flag2 && !flag && reader.LocalName == "Schema" && reader.NamespaceURI == "urn:schemas-microsoft-com:xml-data")
5190 {
5191 ReadXDRSchema(reader);
5192 flag2 = true;
5193 isXdr = true;
5194 continue;
5195 }
5196 if (reader.LocalName == "schema" && reader.NamespaceURI == "http://www.w3.org/2001/XMLSchema")
5197 {
5199 flag2 = true;
5200 continue;
5201 }
5202 if (reader.LocalName == "schema" && reader.NamespaceURI.StartsWith("http://www.w3.org/", StringComparison.Ordinal))
5203 {
5204 if (DataSet != null)
5205 {
5207 }
5208 else
5209 {
5211 }
5212 throw ExceptionBuilder.DataSetUnsupportedSchema("http://www.w3.org/2001/XMLSchema");
5213 }
5214 if (reader.LocalName == "diffgram" && reader.NamespaceURI == "urn:schemas-microsoft-com:xml-diffgram-v1")
5215 {
5216 ReadXmlDiffgram(reader);
5217 flag3 = true;
5218 result = XmlReadMode.DiffGram;
5219 continue;
5220 }
5221 flag = true;
5222 if (!flag2 && Columns.Count == 0)
5223 {
5224 XmlNode newChild = xmlDocument.ReadNode(reader);
5225 xmlElement.AppendChild(newChild);
5226 continue;
5227 }
5228 if (xmlDataLoader == null)
5229 {
5231 }
5232 xmlDataLoader.LoadData(reader);
5233 result = (flag2 ? XmlReadMode.ReadSchema : XmlReadMode.IgnoreSchema);
5234 }
5235 ReadEndElement(reader);
5236 xmlDocument.AppendChild(xmlElement);
5237 if (!flag2 && Columns.Count == 0)
5238 {
5239 if (IsEmptyXml(reader))
5240 {
5241 reader.Read();
5242 return result;
5243 }
5245 }
5246 if (xmlDataLoader == null)
5247 {
5248 xmlDataLoader = new XmlDataLoader(this, isXdr, ignoreSchema: false);
5249 }
5250 }
5252 return result;
5253 }
5254 finally
5255 {
5256 }
5257 }
5258 finally
5259 {
5260 disposable?.Dispose();
5261 DataCommonEventSource.Log.ExitScope(scopeId);
5262 }
5263 }
5264
5265 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
5267 {
5268 IDisposable disposable = null;
5270 try
5271 {
5273 bool flag = false;
5274 bool flag2 = false;
5275 bool isXdr = false;
5276 int depth = -1;
5277 XmlReadMode result = mode;
5278 rowDiffIdUsageSection.Prepare(this);
5279 if (reader == null)
5280 {
5281 return result;
5282 }
5283 bool flag3 = false;
5284 if (DataSet != null)
5285 {
5288 }
5289 else
5290 {
5292 EnforceConstraints = false;
5293 }
5294 if (reader is XmlTextReader)
5295 {
5296 ((XmlTextReader)reader).WhitespaceHandling = WhitespaceHandling.Significant;
5297 }
5299 if (mode != XmlReadMode.Fragment && reader.NodeType == XmlNodeType.Element)
5300 {
5301 depth = reader.Depth;
5302 }
5303 reader.MoveToContent();
5304 if (Columns.Count == 0 && IsEmptyXml(reader))
5305 {
5306 reader.Read();
5307 return result;
5308 }
5310 if (reader.NodeType == XmlNodeType.Element)
5311 {
5312 XmlElement xmlElement = null;
5313 if (mode == XmlReadMode.Fragment)
5314 {
5315 xmlDocument.AppendChild(xmlDocument.CreateElement("ds_sqlXmlWraPPeR"));
5316 xmlElement = xmlDocument.DocumentElement;
5317 }
5318 else
5319 {
5320 if (reader.LocalName == "diffgram" && reader.NamespaceURI == "urn:schemas-microsoft-com:xml-diffgram-v1")
5321 {
5322 if (mode == XmlReadMode.DiffGram || mode == XmlReadMode.IgnoreSchema)
5323 {
5324 if (Columns.Count == 0)
5325 {
5326 if (reader.IsEmptyElement)
5327 {
5328 reader.Read();
5329 return XmlReadMode.DiffGram;
5330 }
5332 }
5333 ReadXmlDiffgram(reader);
5334 ReadEndElement(reader);
5335 }
5336 else
5337 {
5338 reader.Skip();
5339 }
5341 return result;
5342 }
5343 if (reader.LocalName == "Schema" && reader.NamespaceURI == "urn:schemas-microsoft-com:xml-data")
5344 {
5345 if (mode != XmlReadMode.IgnoreSchema && mode != XmlReadMode.InferSchema)
5346 {
5347 ReadXDRSchema(reader);
5348 }
5349 else
5350 {
5351 reader.Skip();
5352 }
5354 return result;
5355 }
5356 if (reader.LocalName == "schema" && reader.NamespaceURI == "http://www.w3.org/2001/XMLSchema")
5357 {
5358 if (mode != XmlReadMode.IgnoreSchema && mode != XmlReadMode.InferSchema)
5359 {
5361 }
5362 else
5363 {
5364 reader.Skip();
5365 }
5367 return result;
5368 }
5369 if (reader.LocalName == "schema" && reader.NamespaceURI.StartsWith("http://www.w3.org/", StringComparison.Ordinal))
5370 {
5371 if (DataSet != null)
5372 {
5374 }
5375 else
5376 {
5378 }
5379 throw ExceptionBuilder.DataSetUnsupportedSchema("http://www.w3.org/2001/XMLSchema");
5380 }
5381 xmlElement = xmlDocument.CreateElement(reader.Prefix, reader.LocalName, reader.NamespaceURI);
5382 if (reader.HasAttributes)
5383 {
5384 int attributeCount = reader.AttributeCount;
5385 for (int i = 0; i < attributeCount; i++)
5386 {
5387 reader.MoveToAttribute(i);
5388 if (reader.NamespaceURI.Equals("http://www.w3.org/2000/xmlns/"))
5389 {
5390 xmlElement.SetAttribute(reader.Name, reader.GetAttribute(i));
5391 continue;
5392 }
5393 XmlAttribute xmlAttribute = xmlElement.SetAttributeNode(reader.LocalName, reader.NamespaceURI);
5394 xmlAttribute.Prefix = reader.Prefix;
5395 xmlAttribute.Value = reader.GetAttribute(i);
5396 }
5397 }
5398 reader.Read();
5399 }
5400 while (MoveToElement(reader, depth))
5401 {
5402 if (reader.LocalName == "Schema" && reader.NamespaceURI == "urn:schemas-microsoft-com:xml-data")
5403 {
5404 if (!flag && !flag2 && mode != XmlReadMode.IgnoreSchema && mode != XmlReadMode.InferSchema)
5405 {
5406 ReadXDRSchema(reader);
5407 flag = true;
5408 isXdr = true;
5409 }
5410 else
5411 {
5412 reader.Skip();
5413 }
5414 continue;
5415 }
5416 if (reader.LocalName == "schema" && reader.NamespaceURI == "http://www.w3.org/2001/XMLSchema")
5417 {
5418 if (mode != XmlReadMode.IgnoreSchema && mode != XmlReadMode.InferSchema)
5419 {
5421 flag = true;
5422 }
5423 else
5424 {
5425 reader.Skip();
5426 }
5427 continue;
5428 }
5429 if (reader.LocalName == "diffgram" && reader.NamespaceURI == "urn:schemas-microsoft-com:xml-diffgram-v1")
5430 {
5431 if (mode == XmlReadMode.DiffGram || mode == XmlReadMode.IgnoreSchema)
5432 {
5433 if (Columns.Count == 0)
5434 {
5435 if (reader.IsEmptyElement)
5436 {
5437 reader.Read();
5438 return XmlReadMode.DiffGram;
5439 }
5441 }
5442 ReadXmlDiffgram(reader);
5443 result = XmlReadMode.DiffGram;
5444 }
5445 else
5446 {
5447 reader.Skip();
5448 }
5449 continue;
5450 }
5451 if (reader.LocalName == "schema" && reader.NamespaceURI.StartsWith("http://www.w3.org/", StringComparison.Ordinal))
5452 {
5453 if (DataSet != null)
5454 {
5456 }
5457 else
5458 {
5460 }
5461 throw ExceptionBuilder.DataSetUnsupportedSchema("http://www.w3.org/2001/XMLSchema");
5462 }
5463 if (mode == XmlReadMode.DiffGram)
5464 {
5465 reader.Skip();
5466 continue;
5467 }
5468 flag2 = true;
5469 if (mode == XmlReadMode.InferSchema)
5470 {
5471 XmlNode newChild = xmlDocument.ReadNode(reader);
5472 xmlElement.AppendChild(newChild);
5473 continue;
5474 }
5475 if (Columns.Count == 0)
5476 {
5478 }
5479 if (xmlDataLoader == null)
5480 {
5481 xmlDataLoader = new XmlDataLoader(this, isXdr, xmlElement, mode == XmlReadMode.IgnoreSchema);
5482 }
5483 xmlDataLoader.LoadData(reader);
5484 }
5485 ReadEndElement(reader);
5486 xmlDocument.AppendChild(xmlElement);
5487 if (xmlDataLoader == null)
5488 {
5489 xmlDataLoader = new XmlDataLoader(this, isXdr, mode == XmlReadMode.IgnoreSchema);
5490 }
5491 switch (mode)
5492 {
5493 case XmlReadMode.DiffGram:
5495 return result;
5496 case XmlReadMode.InferSchema:
5497 if (Columns.Count == 0)
5498 {
5500 }
5501 break;
5502 }
5503 }
5505 return result;
5506 }
5507 finally
5508 {
5509 disposable?.Dispose();
5510 }
5511 }
5512
5513 internal void ReadEndElement(XmlReader reader)
5514 {
5515 while (reader.NodeType == XmlNodeType.Whitespace)
5516 {
5517 reader.Skip();
5518 }
5519 if (reader.NodeType == XmlNodeType.None)
5520 {
5521 reader.Skip();
5522 }
5523 else if (reader.NodeType == XmlNodeType.EndElement)
5524 {
5525 reader.ReadEndElement();
5526 }
5527 }
5528
5529 internal void ReadXDRSchema(XmlReader reader)
5530 {
5532 xmlDocument.ReadNode(reader);
5533 }
5534
5535 internal bool MoveToElement(XmlReader reader, int depth)
5536 {
5537 while (!reader.EOF && reader.NodeType != XmlNodeType.EndElement && reader.NodeType != XmlNodeType.Element && reader.Depth > depth)
5538 {
5539 reader.Read();
5540 }
5541 return reader.NodeType == XmlNodeType.Element;
5542 }
5543
5544 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
5545 private void ReadXmlDiffgram(XmlReader reader)
5546 {
5547 int depth = reader.Depth;
5549 EnforceConstraints = false;
5550 bool flag;
5552 if (Rows.Count == 0)
5553 {
5554 flag = true;
5555 dataTable = this;
5556 }
5557 else
5558 {
5559 flag = false;
5560 dataTable = Clone();
5562 }
5564 reader.MoveToContent();
5565 if (reader.LocalName != "diffgram" && reader.NamespaceURI != "urn:schemas-microsoft-com:xml-diffgram-v1")
5566 {
5567 return;
5568 }
5569 reader.Read();
5570 if (reader.NodeType == XmlNodeType.Whitespace)
5571 {
5572 MoveToElement(reader, reader.Depth - 1);
5573 }
5575 if (reader.Depth > depth)
5576 {
5577 if (reader.NamespaceURI != "urn:schemas-microsoft-com:xml-diffgram-v1" && reader.NamespaceURI != "urn:schemas-microsoft-com:xml-msdata")
5578 {
5580 XmlElement topNode = xmlDocument.CreateElement(reader.Prefix, reader.LocalName, reader.NamespaceURI);
5581 reader.Read();
5582 if (reader.Depth - 1 > depth)
5583 {
5586 xmlDataLoader.LoadData(reader);
5587 }
5588 ReadEndElement(reader);
5589 }
5590 if ((reader.LocalName == "before" && reader.NamespaceURI == "urn:schemas-microsoft-com:xml-diffgram-v1") || (reader.LocalName == "errors" && reader.NamespaceURI == "urn:schemas-microsoft-com:xml-diffgram-v1"))
5591 {
5593 xMLDiffLoader.LoadDiffGram(dataTable, reader);
5594 }
5595 while (reader.Depth > depth)
5596 {
5597 reader.Read();
5598 }
5599 ReadEndElement(reader);
5600 }
5601 if (dataTable.Rows._nullInList > 0)
5602 {
5604 }
5607 list.Add(this);
5608 CreateTableList(this, list);
5609 for (int i = 0; i < list.Count; i++)
5610 {
5611 DataRelation[] nestedParentRelations = list[i].NestedParentRelations;
5613 foreach (DataRelation dataRelation in array)
5614 {
5615 if (dataRelation == null || dataRelation.ParentTable != list[i])
5616 {
5617 continue;
5618 }
5619 foreach (DataRow row in list[i].Rows)
5620 {
5622 foreach (DataRelation rel in array2)
5623 {
5624 row.CheckForLoops(rel);
5625 }
5626 }
5627 }
5628 }
5629 if (!flag)
5630 {
5632 }
5634 }
5635
5636 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
5637 internal void ReadXSDSchema(XmlReader reader, bool denyResolving)
5638 {
5640 while (reader.LocalName == "schema" && reader.NamespaceURI == "http://www.w3.org/2001/XMLSchema")
5641 {
5642 XmlSchema schema = XmlSchema.Read(reader, null);
5644 ReadEndElement(reader);
5645 }
5646 xmlSchemaSet.Compile();
5648 xSDSchema.LoadSchema(xmlSchemaSet, this);
5649 }
5650
5651 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
5653 {
5654 if (stream != null)
5655 {
5657 }
5658 }
5659
5660 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
5661 public void ReadXmlSchema(TextReader? reader)
5662 {
5663 if (reader != null)
5664 {
5665 ReadXmlSchema(new XmlTextReader(reader), denyResolving: false);
5666 }
5667 }
5668
5669 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
5670 public void ReadXmlSchema(string fileName)
5671 {
5673 try
5674 {
5676 }
5677 finally
5678 {
5679 xmlTextReader.Close();
5680 }
5681 }
5682
5683 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
5684 public void ReadXmlSchema(XmlReader? reader)
5685 {
5686 ReadXmlSchema(reader, denyResolving: false);
5687 }
5688
5689 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
5690 internal void ReadXmlSchema(XmlReader reader, bool denyResolving)
5691 {
5692 long scopeId = DataCommonEventSource.Log.EnterScope("<ds.DataTable.ReadXmlSchema|INFO> {0}, denyResolving={1}", ObjectID, denyResolving);
5693 try
5694 {
5695 DataSet dataSet = new DataSet();
5697 dataSet.ReadXmlSchema(reader, denyResolving);
5698 string mainTableName = dataSet.MainTableName;
5699 if (string.IsNullOrEmpty(_tableName) && string.IsNullOrEmpty(mainTableName))
5700 {
5701 return;
5702 }
5703 DataTable dataTable = null;
5704 if (!string.IsNullOrEmpty(_tableName))
5705 {
5706 if (!string.IsNullOrEmpty(Namespace))
5707 {
5709 }
5710 else
5711 {
5712 int num = dataSet.Tables.InternalIndexOf(_tableName);
5713 if (num > -1)
5714 {
5715 dataTable = dataSet.Tables[num];
5716 }
5717 }
5718 }
5719 else
5720 {
5721 string tableNamespace = string.Empty;
5722 int num2 = mainTableName.IndexOf(':');
5723 if (num2 > -1)
5724 {
5725 tableNamespace = mainTableName.Substring(0, num2);
5726 }
5727 string name = mainTableName.Substring(num2 + 1, mainTableName.Length - num2 - 1);
5728 dataTable = dataSet.Tables[name, tableNamespace];
5729 }
5730 if (dataTable == null)
5731 {
5732 string empty = string.Empty;
5733 empty = (string.IsNullOrEmpty(_tableName) ? mainTableName : ((Namespace.Length > 0) ? (Namespace + ":" + _tableName) : _tableName));
5735 }
5738 list.Add(dataTable);
5742 if (list2.Count == 0)
5743 {
5744 if (Columns.Count == 0)
5745 {
5747 dataTable2.CloneTo(this, null, skipExpressionColumns: false);
5748 if (DataSet == null && _tableNamespace == null)
5749 {
5750 _tableNamespace = dataTable2.Namespace;
5751 }
5752 }
5753 return;
5754 }
5755 if (string.IsNullOrEmpty(TableName))
5756 {
5757 TableName = dataTable.TableName;
5758 if (!string.IsNullOrEmpty(dataTable.Namespace))
5759 {
5760 Namespace = dataTable.Namespace;
5761 }
5762 }
5763 if (DataSet == null)
5764 {
5765 DataSet dataSet2 = new DataSet(dataSet.DataSetName);
5766 dataSet2.SetLocaleValue(dataSet.Locale, dataSet.ShouldSerializeLocale());
5767 dataSet2.CaseSensitive = dataSet.CaseSensitive;
5768 dataSet2.Namespace = dataSet.Namespace;
5769 dataSet2._mainTableName = dataSet._mainTableName;
5770 dataSet2.RemotingFormat = dataSet.RemotingFormat;
5771 dataSet2.Tables.Add(this);
5772 }
5774 foreach (DataTable item in list)
5775 {
5776 DataTable dataTable3 = DataSet.Tables[item._tableName, item.Namespace];
5777 DataTable dataTable4 = dataSet.Tables[item._tableName, item.Namespace];
5778 foreach (Constraint constraint in dataTable4.Constraints)
5779 {
5780 if (constraint is ForeignKeyConstraint foreignKeyConstraint && foreignKeyConstraint.Table != foreignKeyConstraint.RelatedTable && list.Contains(foreignKeyConstraint.Table) && list.Contains(foreignKeyConstraint.RelatedTable))
5781 {
5783 if (!dataTable3.Constraints.Contains(foreignKeyConstraint2.ConstraintName))
5784 {
5786 }
5787 }
5788 }
5789 }
5790 foreach (DataRelation item2 in list2)
5791 {
5792 if (!DataSet.Relations.Contains(item2.RelationName))
5793 {
5795 }
5796 }
5797 bool flag = false;
5798 foreach (DataTable item3 in list)
5799 {
5800 foreach (DataColumn column in item3.Columns)
5801 {
5802 flag = false;
5803 if (column.Expression.Length != 0)
5804 {
5805 DataColumn[] dependency = column.DataExpression.GetDependency();
5806 for (int i = 0; i < dependency.Length; i++)
5807 {
5808 if (!list.Contains(dependency[i].Table))
5809 {
5810 flag = true;
5811 break;
5812 }
5813 }
5814 }
5815 if (!flag)
5816 {
5817 DataSet.Tables[item3.TableName, item3.Namespace].Columns[column.ColumnName].Expression = column.Expression;
5818 }
5819 }
5820 flag = false;
5821 }
5822 }
5823 finally
5824 {
5825 DataCommonEventSource.Log.ExitScope(scopeId);
5826 }
5827 }
5828
5830 {
5831 foreach (DataRelation childRelation in currentTable.ChildRelations)
5832 {
5833 if (!tableList.Contains(childRelation.ChildTable))
5834 {
5835 tableList.Add(childRelation.ChildTable);
5837 }
5838 }
5839 }
5840
5842 {
5843 foreach (DataTable table in tableList)
5844 {
5845 foreach (DataRelation childRelation in table.ChildRelations)
5846 {
5847 if (tableList.Contains(childRelation.ChildTable) && tableList.Contains(childRelation.ParentTable))
5848 {
5850 }
5851 }
5852 }
5853 }
5854
5873
5875 {
5876 return GetXmlSchema();
5877 }
5878
5879 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
5880 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2046:UnrecognizedReflectionPattern", Justification = "https://github.com/mono/linker/issues/1187 Trimmer thinks this implements IXmlSerializable.GetSchema() and warns about not matching attributes.")]
5881 protected virtual XmlSchema? GetSchema()
5882 {
5883 if (GetType() == typeof(DataTable))
5884 {
5885 return null;
5886 }
5889 if (xmlWriter != null)
5890 {
5891 new XmlTreeGen(SchemaFormat.WebService).Save(this, xmlWriter);
5892 }
5894 return XmlSchema.Read(new XmlTextReader(memoryStream), null);
5895 }
5896
5897 [RequiresUnreferencedCode("DataTable.GetSchema uses TypeDescriptor and XmlSerialization underneath which are not trimming safe. Members from serialized types may be trimmed if not referenced directly.")]
5899 {
5900 return GetSchema();
5901 }
5902
5904 {
5906 bool normalized = true;
5907 if (xmlTextParser != null)
5908 {
5909 normalized = xmlTextParser.Normalized;
5911 }
5913 if (xmlTextParser != null)
5914 {
5916 }
5917 }
5918
5919 [RequiresUnreferencedCode("DataTable.ReadXml uses XmlSerialization underneath which is not trimming safe. Members from serialized types may be trimmed if not referenced directly.")]
5921 {
5922 ReadXmlSerializable(reader);
5923 }
5924
5929
5930 [RequiresUnreferencedCode("DataTable.WriteXml uses XmlSerialization underneath which is not trimming safe. Members from serialized types may be trimmed if not referenced directly.")]
5932 {
5934 WriteXml(writer, XmlWriteMode.DiffGram, writeHierarchy: false);
5935 }
5936
5937 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
5938 protected virtual void ReadXmlSerializable(XmlReader? reader)
5939 {
5940 ReadXml(reader, XmlReadMode.DiffGram, denyResolving: true);
5941 }
5942
5944 {
5945 if (_dependentColumns == null)
5946 {
5948 }
5950 {
5952 }
5953 }
5954
5962
5963 internal void EvaluateExpressions()
5964 {
5965 if (_dependentColumns == null || 0 >= _dependentColumns.Count)
5966 {
5967 return;
5968 }
5969 foreach (DataRow row in Rows)
5970 {
5971 if (row._oldRecord != -1 && row._oldRecord != row._newRecord)
5972 {
5974 }
5975 if (row._newRecord != -1)
5976 {
5978 }
5979 if (row._tempRecord != -1)
5980 {
5982 }
5983 }
5984 }
5985
5986 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "This is unsafe only when columns have associated expression. All ways to add such expression are marked unsafe.")]
5988 {
5989 if (action == DataRowAction.Add || action == DataRowAction.Change || (action == DataRowAction.Rollback && (row._oldRecord != -1 || row._newRecord != -1)))
5990 {
5991 if (row._oldRecord != -1 && row._oldRecord != row._newRecord)
5992 {
5994 }
5995 if (row._newRecord != -1)
5996 {
5998 }
5999 if (row._tempRecord != -1)
6000 {
6002 }
6003 return;
6004 }
6005 switch (action)
6006 {
6007 case DataRowAction.Rollback:
6008 if (row._oldRecord != -1 || row._newRecord != -1)
6009 {
6010 break;
6011 }
6012 goto case DataRowAction.Delete;
6013 case DataRowAction.Delete:
6014 if (_dependentColumns == null)
6015 {
6016 break;
6017 }
6019 {
6020 if (dependentColumn.DataExpression == null || !dependentColumn.DataExpression.HasLocalAggregate() || dependentColumn.Table != this)
6021 {
6022 continue;
6023 }
6024 for (int i = 0; i < Rows.Count; i++)
6025 {
6026 DataRow dataRow = Rows[i];
6027 if (dataRow._oldRecord != -1 && dataRow._oldRecord != dataRow._newRecord)
6028 {
6030 }
6031 }
6032 for (int j = 0; j < Rows.Count; j++)
6033 {
6035 if (dataRow2._tempRecord != -1)
6036 {
6038 }
6039 }
6040 for (int k = 0; k < Rows.Count; k++)
6041 {
6043 if (dataRow3._newRecord != -1)
6044 {
6046 }
6047 }
6048 break;
6049 }
6050 if (cachedRows == null)
6051 {
6052 break;
6053 }
6054 {
6055 foreach (DataRow cachedRow in cachedRows)
6056 {
6057 if (cachedRow._oldRecord != -1 && cachedRow._oldRecord != cachedRow._newRecord)
6058 {
6059 cachedRow.Table.EvaluateDependentExpressions(cachedRow.Table._dependentColumns, cachedRow, DataRowVersion.Original, null);
6060 }
6061 if (cachedRow._newRecord != -1)
6062 {
6063 cachedRow.Table.EvaluateDependentExpressions(cachedRow.Table._dependentColumns, cachedRow, DataRowVersion.Current, null);
6064 }
6065 if (cachedRow._tempRecord != -1)
6066 {
6067 cachedRow.Table.EvaluateDependentExpressions(cachedRow.Table._dependentColumns, cachedRow, DataRowVersion.Proposed, null);
6068 }
6069 }
6070 break;
6071 }
6072 }
6073 }
6074
6076 {
6077 int count = column._table.Rows.Count;
6078 if (column.DataExpression.IsTableAggregate() && count > 0)
6079 {
6080 object value = column.DataExpression.Evaluate();
6081 for (int i = 0; i < count; i++)
6082 {
6083 DataRow dataRow = column._table.Rows[i];
6084 if (dataRow._oldRecord != -1 && dataRow._oldRecord != dataRow._newRecord)
6085 {
6086 column[dataRow._oldRecord] = value;
6087 }
6088 if (dataRow._newRecord != -1)
6089 {
6090 column[dataRow._newRecord] = value;
6091 }
6092 if (dataRow._tempRecord != -1)
6093 {
6094 column[dataRow._tempRecord] = value;
6095 }
6096 }
6097 }
6098 else
6099 {
6100 for (int j = 0; j < count; j++)
6101 {
6102 DataRow dataRow2 = column._table.Rows[j];
6103 if (dataRow2._oldRecord != -1 && dataRow2._oldRecord != dataRow2._newRecord)
6104 {
6105 column[dataRow2._oldRecord] = column.DataExpression.Evaluate(dataRow2, DataRowVersion.Original);
6106 }
6107 if (dataRow2._newRecord != -1)
6108 {
6109 column[dataRow2._newRecord] = column.DataExpression.Evaluate(dataRow2, DataRowVersion.Current);
6110 }
6111 if (dataRow2._tempRecord != -1)
6112 {
6113 column[dataRow2._tempRecord] = column.DataExpression.Evaluate(dataRow2, DataRowVersion.Proposed);
6114 }
6115 }
6116 }
6117 column._table.ResetInternalIndexes(column);
6119 }
6120
6122 {
6123 if (column._dependentColumns == null)
6124 {
6125 return;
6126 }
6127 foreach (DataColumn dependentColumn in column._dependentColumns)
6128 {
6129 if (dependentColumn._table != null && column != dependentColumn)
6130 {
6132 }
6133 }
6134 }
6135
6137 {
6138 if (columns == null)
6139 {
6140 return;
6141 }
6142 int count = columns.Count;
6143 for (int i = 0; i < count; i++)
6144 {
6145 if (columns[i].Table != this)
6146 {
6147 continue;
6148 }
6150 if (dataColumn.DataExpression != null && dataColumn.DataExpression.HasLocalAggregate())
6151 {
6152 DataRowVersion dataRowVersion = ((version == DataRowVersion.Proposed) ? DataRowVersion.Default : version);
6153 bool flag = dataColumn.DataExpression.IsTableAggregate();
6154 object newValue = null;
6155 if (flag)
6156 {
6157 newValue = dataColumn.DataExpression.Evaluate(row, dataRowVersion);
6158 }
6159 for (int j = 0; j < Rows.Count; j++)
6160 {
6161 DataRow dataRow = Rows[j];
6162 if (dataRow.RowState != DataRowState.Deleted && (dataRowVersion != DataRowVersion.Original || (dataRow._oldRecord != -1 && dataRow._oldRecord != dataRow._newRecord)))
6163 {
6164 if (!flag)
6165 {
6166 newValue = dataColumn.DataExpression.Evaluate(dataRow, dataRowVersion);
6167 }
6169 }
6170 }
6171 }
6172 else if (row.RowState != DataRowState.Deleted && (version != DataRowVersion.Original || (row._oldRecord != -1 && row._oldRecord != row._newRecord)))
6173 {
6174 SilentlySetValue(row, dataColumn, version, (dataColumn.DataExpression == null) ? dataColumn.DefaultValue : dataColumn.DataExpression.Evaluate(row, version));
6175 }
6176 }
6178 for (int k = 0; k < count; k++)
6179 {
6181 if (dataColumn2.Table == this && (dataColumn2.DataExpression == null || dataColumn2.DataExpression.HasLocalAggregate()))
6182 {
6183 continue;
6184 }
6185 DataRowVersion dataRowVersion2 = ((version == DataRowVersion.Proposed) ? DataRowVersion.Default : version);
6186 if (cachedRows != null)
6187 {
6188 foreach (DataRow cachedRow in cachedRows)
6189 {
6190 if (cachedRow.Table == dataColumn2.Table && (dataRowVersion2 != DataRowVersion.Original || cachedRow._newRecord != cachedRow._oldRecord) && cachedRow != null && cachedRow.RowState != DataRowState.Deleted && (version != DataRowVersion.Original || cachedRow._oldRecord != -1))
6191 {
6192 object newValue2 = dataColumn2.DataExpression.Evaluate(cachedRow, dataRowVersion2);
6194 }
6195 }
6196 }
6197 for (int l = 0; l < ParentRelations.Count; l++)
6198 {
6200 if (dataRelation.ParentTable != dataColumn2.Table)
6201 {
6202 continue;
6203 }
6204 DataRow[] parentRows = row.GetParentRows(dataRelation, version);
6205 foreach (DataRow dataRow2 in parentRows)
6206 {
6207 if ((cachedRows == null || !cachedRows.Contains(dataRow2)) && (dataRowVersion2 != DataRowVersion.Original || dataRow2._newRecord != dataRow2._oldRecord) && dataRow2 != null && dataRow2.RowState != DataRowState.Deleted && (version != DataRowVersion.Original || dataRow2._oldRecord != -1))
6208 {
6209 object newValue3 = dataColumn2.DataExpression.Evaluate(dataRow2, dataRowVersion2);
6211 }
6212 }
6213 }
6214 for (int n = 0; n < ChildRelations.Count; n++)
6215 {
6217 if (dataRelation2.ChildTable != dataColumn2.Table)
6218 {
6219 continue;
6220 }
6221 DataRow[] childRows = row.GetChildRows(dataRelation2, version);
6222 foreach (DataRow dataRow3 in childRows)
6223 {
6224 if ((cachedRows == null || !cachedRows.Contains(dataRow3)) && (dataRowVersion2 != DataRowVersion.Original || dataRow3._newRecord != dataRow3._oldRecord) && dataRow3 != null && dataRow3.RowState != DataRowState.Deleted && (version != DataRowVersion.Original || dataRow3._oldRecord != -1))
6225 {
6226 object newValue4 = dataColumn2.DataExpression.Evaluate(dataRow3, dataRowVersion2);
6228 }
6229 }
6230 }
6231 }
6232 }
6233}
static ? object CreateInstance([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors|DynamicallyAccessedMemberTypes.NonPublicConstructors)] Type type, BindingFlags bindingAttr, Binder? binder, object?[]? args, CultureInfo? culture)
Definition Activator.cs:17
static unsafe Array CreateInstance(Type elementType, int length)
Definition Array.cs:473
static unsafe void Copy(Array sourceArray, Array destinationArray, int length)
Definition Array.cs:624
virtual void OnDeserialization(object? sender)
bool ICollection< KeyValuePair< TKey, TValue > >. Remove(KeyValuePair< TKey, TValue > keyValuePair)
void CopyTo(KeyValuePair< TKey, TValue >[] array, int index)
bool ICollection< KeyValuePair< TKey, TValue > >. Contains(KeyValuePair< TKey, TValue > keyValuePair)
void Add(TKey key, TValue value)
virtual void OnDeserialization(object? sender)
virtual ICollection Keys
Definition Hashtable.cs:532
static bool ToBoolean([NotNullWhen(true)] object? value)
Definition Convert.cs:508
static readonly DBNull Value
Definition DBNull.cs:8
static ArgumentOutOfRangeException InvalidMissingSchemaAction(MissingSchemaAction value)
Definition ADP.cs:134
static bool IsCatchableExceptionType(Exception e)
Definition ADP.cs:790
static bool IsCatchableOrSecurityExceptionType(Exception e)
Definition ADP.cs:800
static void TraceExceptionWithoutRethrow(Exception e)
Definition ADP.cs:673
static bool IsTypeCustomType(Type type)
void Remove(Constraint constraint)
void Add(Constraint constraint)
Constraint FindConstraint(Constraint constraint)
void AddAt(int index, DataColumn column)
static readonly DataCommonEventSource Log
override void CopyTo(Array ar, int index)
void ArrayInsert(DataRow row, int pos)
void OnDataRowCreated(DataRow row)
Definition DataSet.cs:2602
DataRelationCollection Relations
Definition DataSet.cs:393
DataTableCollection Tables
Definition DataSet.cs:396
string GetXmlSchemaForRemoting(DataTable table)
Definition DataSet.cs:1255
void RestoreEnforceConstraints(bool value)
Definition DataSet.cs:783
SerializationFormat RemotingFormat
Definition DataSet.cs:109
bool ValidateLocaleConstraint()
Definition DataSet.cs:2763
CultureInfo Locale
Definition DataSet.cs:337
bool ValidateCaseConstraint()
Definition DataSet.cs:2724
void OnClearFunctionCalled(DataTable table)
Definition DataSet.cs:2607
string GetRemotingDiffGram(DataTable table)
Definition DataSet.cs:1209
DataViewManager DefaultViewManager
Definition DataSet.cs:176
void RegisterName(string name, string tbNamespace)
void SetNewRecordWorker(DataRow row, int proposedRecord, DataRowAction action, bool isInMerge, bool suppressEnsurePropertyChanged, int position, bool fireEvent, out Exception deferredException)
readonly DataColumnCollection _columnCollection
Definition DataTable.cs:64
DataTable(string? tableName)
DataColumn AddUniqueKey(int position)
DataRelationCollection _childRelationsCollection
Definition DataTable.cs:72
void Merge(DataTable table, bool preserveChanges, MissingSchemaAction missingSchemaAction)
virtual void OnRowDeleted(DataRowChangeEventArgs e)
virtual void Load(IDataReader reader, LoadOption loadOption, FillErrorEventHandler? errorHandler)
bool SetCaseSensitiveValue(bool isCaseSensitive, bool userSet, bool resetIndexes)
void OnRemoveColumnInternal(DataColumn column)
DataColumnChangeEventHandler _onColumnChangedDelegate
Definition DataTable.cs:172
void CheckNotModifying(DataRow row)
XmlReadMode ReadXml(XmlReader reader, bool denyResolving)
bool CheckForClosureOnExpressionTables(List< DataTable > tableList)
void WriteXmlSchema(string fileName)
void RecordStateChanged(int record1, DataViewRowState oldState1, DataViewRowState newState1, int record2, DataViewRowState oldState2, DataViewRowState newState2)
void WriteXmlSchema(string fileName, bool writeHierarchy)
DataTableClearEventHandler? TableCleared
void DeserializeTableData(SerializationInfo info, StreamingContext context, int serIndex)
virtual void OnTableClearing(DataTableClearEventArgs e)
void DeserializeTableSchema(SerializationInfo info, StreamingContext context, bool isSingleTable)
Index GetIndex(string sort, DataViewRowState recordStates, IFilter rowFilter)
DataColumn[] _delayedSetPrimaryKey
Definition DataTable.cs:128
DataRowChangeEventHandler? RowChanged
void ReadXSDSchema(XmlReader reader, bool denyResolving)
void Merge(DataTable table)
void WriteXmlSchema(XmlWriter? writer)
CompareInfo _compareInfo
Definition DataTable.cs:98
PropertyDescriptorCollection GetPropertyDescriptorCollection(Attribute[] attributes)
void WriteXml(string fileName)
DataRow NewUninitializedRow()
void SerializeTableSchema(SerializationInfo info, StreamingContext context, bool isSingleTable)
virtual Type GetRowType()
void NewRowCreated(DataRow row)
DataTable CloneTo(DataTable clone, DataSet cloneDS, bool skipExpressionColumns)
void WriteXmlSchema(XmlWriter? writer, bool writeHierarchy)
EventHandler _onInitialized
Definition DataTable.cs:184
void ReadXmlSerializableInternal(XmlReader reader)
DataRow AddRecords(int oldRecord, int newRecord)
int GetSpecialHashCode(string name)
void InsertRow(DataRow row, long proposedID)
int[] InsertRecordToIndexes(DataRow row, DataRowVersion version)
void SerializeExpressionColumns(SerializationInfo info, StreamingContext context, int serIndex)
static XmlSchemaComplexType GetDataTableSchema(XmlSchemaSet? schemaSet)
PropertyCollection _extendedProperties
Definition DataTable.cs:82
readonly ReaderWriterLockSlim _indexesLock
Definition DataTable.cs:194
void EvaluateExpressions(DataRow row, DataRowAction action, List< DataRow > cachedRows)
void Clear(bool clearAll)
List< Index > _shadowIndexes
Definition DataTable.cs:78
void WriteXml(TextWriter? writer)
DataRow LoadRow(object[] values, LoadOption loadOption, Index searchIndex)
readonly List< Index > _indexes
Definition DataTable.cs:76
void WriteXml(string fileName, XmlWriteMode mode)
void CascadeAll(DataRow row, DataRowAction action)
DataRow[] _emptyDataRowArray
Definition DataTable.cs:154
DataColumnChangeEventHandler? ColumnChanged
Definition DataTable.cs:994
void RaisePropertyChanging(string name)
void WriteXml(TextWriter? writer, XmlWriteMode mode, bool writeHierarchy)
DataRelation[] FindNestedParentRelations()
virtual void Reset()
void ReadXmlSchema(XmlReader reader, bool denyResolving)
DataRow UpdatingAdd(object[] values)
readonly List< DataViewListener > _dataViewListeners
Definition DataTable.cs:190
void WriteXml(XmlWriter? writer)
DataRowCollection Rows
Definition DataTable.cs:701
DataTable CloneHierarchy(DataTable sourceTable, DataSet ds, Hashtable visitedMap)
int Compare(string s1, string s2)
void SetMergeRecords(DataRow row, int newRecord, int oldRecord, DataRowAction action)
DataRowChangeEventArgs OnRowChanged(DataRowChangeEventArgs args, DataRow eRow, DataRowAction eAction)
void Merge(DataTable table, bool preserveChanges)
UniqueConstraint _primaryKey
Definition DataTable.cs:124
DataRow MergeRow(DataRow row, DataRow targetRow, bool preserveChanges, Index idxSearch)
void DeserializeExpressionColumns(SerializationInfo info, StreamingContext context, int serIndex)
bool IsEmptyXml(XmlReader reader)
PropertyChangedEventHandler _onPropertyChangingDelegate
Definition DataTable.cs:182
void WriteXml(string fileName, bool writeHierarchy)
void WriteXml(string fileName, XmlWriteMode mode, bool writeHierarchy)
IFormatProvider _formatProvider
Definition DataTable.cs:102
void SerializeConstraints(SerializationInfo info, StreamingContext context, int serIndex, bool allConstraints)
DataRow[] GetErrors()
void CreateTableList(DataTable currentTable, List< DataTable > tableList)
EventHandler? Initialized
void WriteXmlSchema(Stream? stream)
void EvaluateDependentExpressions(DataColumn column)
DataRow NewRow(int record)
readonly ConstraintCollection _constraintCollection
Definition DataTable.cs:66
XmlSchema GetXmlSchema()
void WriteXml(Stream? stream, XmlWriteMode mode)
void RemoveDependentColumn(DataColumn expressionColumn)
void DeserializeDataTable(SerializationInfo info, StreamingContext context, bool isSingleTable, SerializationFormat remotingFormat)
void ReadXmlSchema(Stream? stream)
string GetInheritedNamespace(List< DataTable > visitedTables)
virtual void OnColumnChanged(DataColumnChangeEventArgs e)
void GetRowAndColumnErrors(int rowIndex, Hashtable rowErrors, Hashtable colErrors)
DataColumn AddForeignKey(DataColumn parentKey)
int NewRecord(int sourceRecord)
virtual DataTable CreateInstance()
IndexField[] NewIndexDesc(DataKey key)
DataRowChangeEventHandler _onRowDeletedDelegate
Definition DataTable.cs:170
DataColumn _colUnique
Definition DataTable.cs:114
bool IsSuffix(string s1, string s2)
DataRow[] Select(string? filterExpression, string? sort, DataViewRowState recordStates)
string DisplayExpressionInternal
Definition DataTable.cs:381
void UpdatePropertyDescriptorCollectionCache()
void ReadXmlDiffgram(XmlReader reader)
DataRowChangeEventHandler? RowDeleting
void AddDependentColumn(DataColumn expressionColumn)
virtual void OnPropertyChanging(PropertyChangedEventArgs pcevent)
ConstraintCollection Constraints
Definition DataTable.cs:332
virtual void OnColumnChanging(DataColumnChangeEventArgs e)
PropertyCollection ExtendedProperties
Definition DataTable.cs:432
void FreeRecord(ref int record)
void ReadXmlSchema(XmlReader? reader)
XmlReadMode ReadXml(XmlReader? reader)
XmlReadMode ReadXml(TextReader? reader)
void ResetInternalIndexes(DataColumn column)
DataColumnCollection Columns
Definition DataTable.cs:327
readonly List< DataView > _delayedViews
Definition DataTable.cs:188
XmlQualifiedName TypeName
Definition DataTable.cs:950
List< DataViewListener > GetListeners()
IndexField[] ParseSortString(string sortString)
void CopyRow(DataTable table, DataRow row)
DataTable? GetChanges()
int IndexOf(string s1, string s2)
object Compute(string? expression, string? filter)
bool ShouldSerializeCaseSensitive()
void RecordChanged(int record)
void InsertRow(DataRow row, int proposedID, int pos)
DataTable(SerializationInfo info, StreamingContext context)
DataRowChangeEventHandler _onRowDeletingDelegate
Definition DataTable.cs:168
DataTable Clone(DataSet cloneDS)
DataRelationCollection _parentRelationsCollection
Definition DataTable.cs:70
DataRelation[] _nestedParentRelations
Definition DataTable.cs:158
DataTableReader CreateDataReader()
void SerializeTableData(SerializationInfo info, StreamingContext context, int serIndex)
StringComparer _hashCodeProvider
Definition DataTable.cs:104
void RestoreConstraint(bool originalEnforceConstraint)
virtual void OnRowChanged(DataRowChangeEventArgs e)
void WriteXmlSchema(Stream? stream, bool writeHierarchy)
void SetDataSet(DataSet dataSet)
DataTableNewRowEventHandler _onTableNewRowDelegate
Definition DataTable.cs:180
void WriteXml(Stream? stream, bool writeHierarchy)
int NewRecordFromArray(object[] value)
void ReadXmlSchema(TextReader? reader)
void WriteXml(XmlWriter? writer, XmlWriteMode mode)
virtual ? XmlSchema GetSchema()
DataRow[] NewRowArray(int size)
void SetOldRecord(DataRow row, int proposedRecord)
DataRow[] Select(string? filterExpression)
CompareOptions _compareFlags
Definition DataTable.cs:100
virtual void OnRowDeleting(DataRowChangeEventArgs e)
DataRowChangeEventArgs OnRowChanging(DataRowChangeEventArgs args, DataRow eRow, DataRowAction eAction)
SerializationFormat _remotingFormat
Definition DataTable.cs:198
void CheckCascadingNamespaceConflict(string realNamespace)
override? ISite Site
Definition DataTable.cs:909
virtual void OnRemoveColumn(DataColumn column)
DataExpression _displayExpression
Definition DataTable.cs:90
Index GetIndex(IndexField[] indexDesc, DataViewRowState recordStates, IFilter rowFilter)
DataRow LoadDataRow(object?[] values, LoadOption loadOption)
static int s_objectTypeCount
Definition DataTable.cs:200
readonly DataRowCollection _rowCollection
Definition DataTable.cs:62
DataRowState ConvertToRowState(BitArray bitStates, int bitIndex)
bool CheckForClosureOnExpressions(DataTable dt, bool writeHierarchy)
void WriteXmlSchema(TextWriter? writer, bool writeHierarchy)
void CheckNamespaceValidityForNestedParentRelations(string ns, DataTable parentTable)
DataColumn AddUniqueKey()
bool UpdatingCurrent(DataRow row, DataRowAction action)
DataColumnChangeEventHandler? ColumnChanging
Definition DataTable.cs:980
XmlSchema IXmlSerializable. GetSchema()
void WriteXml(XmlWriter? writer, bool writeHierarchy)
DataRow FindMergeTarget(DataRow row, DataKey key, Index ndx)
XmlReadMode ReadXml(XmlReader reader, XmlReadMode mode, bool denyResolving)
void RecordChanged(int[] oldIndex, int[] newIndex)
DataTable IncrementalCloneTo(DataTable sourceTable, DataTable targetTable)
void WriteXml(TextWriter? writer, bool writeHierarchy)
DataTable? GetChanges(DataRowState rowStates)
void ReadEndElement(XmlReader reader)
DataRow FindRow(DataKey key, object[] values)
void RestoreIndexEvents(bool forceReset)
void InsertRow(DataRow row, long proposedID, int pos, bool fireEvent)
void WriteXmlSchema(TextWriter? writer)
DataRowChangeEventHandler _onRowChangedDelegate
Definition DataTable.cs:164
DataTableClearEventHandler _onTableClearingDelegate
Definition DataTable.cs:176
void WriteXml(XmlWriter? writer, XmlWriteMode mode, bool writeHierarchy)
DataRow FindRow(DataKey key, object value)
DataRow FindByPrimaryKey(object[] values)
void WriteXml(Stream? stream, XmlWriteMode mode, bool writeHierarchy)
DataRelationCollection ParentRelations
Definition DataTable.cs:572
virtual void EndInit()
XmlReadMode ReadXml(string fileName)
DataRowChangeEventArgs RaiseRowChanging(DataRowChangeEventArgs args, DataRow eRow, DataRowAction eAction)
void CheckNamespaceValidityForNestedRelations(string realNamespace)
virtual void OnTableCleared(DataTableClearEventArgs e)
void Load(IDataReader reader, LoadOption loadOption)
void ReadXDRSchema(XmlReader reader)
readonly int _objectID
Definition DataTable.cs:202
void ImportRow(DataRow? row)
void SerializeDataTable(SerializationInfo info, StreamingContext context, bool isSingleTable, SerializationFormat remotingFormat)
DataTableClearEventHandler _onTableClearedDelegate
Definition DataTable.cs:178
void CommitRow(DataRow row)
DataTable(string? tableName, string? tableNamespace)
void WriteXml(TextWriter? writer, XmlWriteMode mode)
int Compare(string s1, string s2, CompareInfo comparer)
DataTableClearEventHandler? TableClearing
virtual void OnTableNewRow(DataTableNewRowEventArgs e)
CultureInfo _culture
Definition DataTable.cs:94
Index GetIndex(IndexField[] indexDesc)
DataRowChangeEventHandler? RowDeleted
string FormatSortString(IndexField[] indexDesc)
void DeserializeConstraints(SerializationInfo info, StreamingContext context, int serIndex, bool allConstraints)
void AddRow(DataRow row, int proposedID)
void ReadXmlSchema(string fileName)
DataColumnChangeEventHandler _onColumnChangingDelegate
Definition DataTable.cs:174
void DeleteRow(DataRow row)
DataColumn[] PrimaryKey
Definition DataTable.cs:607
void WriteXmlInternal(XmlWriter writer)
List< DataColumn > _dependentColumns
Definition DataTable.cs:160
Index _loadIndexwithOriginalAdded
Definition DataTable.cs:132
DataRowChangeEventHandler? RowChanging
PropertyChangedEventHandler PropertyChanging
virtual DataTable Clone()
void SilentlySetValue(DataRow dr, DataColumn dc, DataRowVersion version, object newValue)
DataRowChangeEventArgs RaiseRowChanging(DataRowChangeEventArgs args, DataRow eRow, DataRowAction eAction, bool fireEvent)
void Load(IDataReader reader)
bool MoveToElement(XmlReader reader, int depth)
void RecordStateChanged(int record, DataViewRowState oldState, DataViewRowState newState)
DataRowChangeEventHandler _onRowChangingDelegate
Definition DataTable.cs:166
bool SetLocaleValue(CultureInfo culture, bool userSet, bool resetIndexes)
void WriteXml(Stream? stream)
override string ToString()
virtual void BeginInit()
virtual void GetObjectData(SerializationInfo info, StreamingContext context)
DataRow[] Select(string? filterExpression, string? sort)
void SetKeyValues(DataKey key, object[] keyValues, int record)
void SetDataRowWithLoadOption(DataRow dataRow, int recordNo, LoadOption loadOption, bool checkReadOnly)
DataRow FindByPrimaryKey(object value)
void RollbackRow(DataRow row)
PropertyDescriptorCollection _propertyDescriptorCollectionCache
Definition DataTable.cs:156
void ConvertToRowError(int rowIndex, Hashtable rowErrors, Hashtable colErrors)
void SetNewRecord(DataRow row, int proposedRecord, DataRowAction action=DataRowAction.Change, bool isInMerge=false, bool fireEvent=true, bool suppressEnsurePropertyChanged=false)
Index _loadIndexwithCurrentDeleted
Definition DataTable.cs:134
void CreateRelationList(List< DataTable > tableList, List< DataRelation > relationList)
DataTableNewRowEventHandler? TableNewRow
void AddRow(DataRow row)
readonly RecordManager _recordManager
Definition DataTable.cs:74
virtual DataRow NewRowFromBuilder(DataRowBuilder builder)
void EvaluateDependentExpressions(List< DataColumn > columns, DataRow row, DataRowVersion version, List< DataRow > cachedRows)
DataRowChangeEventArgs RaiseRowChanged(DataRowChangeEventArgs args, DataRow eRow, DataRowAction eAction)
readonly DataRowBuilder _rowBuilder
Definition DataTable.cs:186
virtual void OnRowChanging(DataRowChangeEventArgs e)
void RemoveRow(DataRow row, bool check)
IndexField[] _primaryIndex
Definition DataTable.cs:126
virtual void ReadXmlSerializable(XmlReader? reader)
DataRelation[] NestedParentRelations
Definition DataTable.cs:586
int[] RemoveRecordFromIndexes(DataRow row, DataRowVersion version)
SerializationFormat RemotingFormat
Definition DataTable.cs:291
DataRelationCollection ChildRelations
Definition DataTable.cs:324
void EvaluateExpressions(DataColumn column)
XmlReadMode ReadXml(Stream? stream)
List< Index > LiveIndexes
Definition DataTable.cs:269
DataRow LoadDataRow(object?[] values, bool fAcceptChanges)
DataRow FindByIndex(Index ndx, object[] key)
DataView CreateDataView(DataTable table)
static Exception ColumnOutOfRange(int index)
static Exception TableMissingPrimaryKey()
static Exception RowAlreadyRemoved()
static Exception RowInsertMissing(string tableName)
static Exception CanNotSetRemotingFormat()
static Exception InValidNestedRelation(string childTableName)
static Exception DataTableInferenceNotSupported()
static Exception CannotAddDuplicate2(string table)
static Exception TableCannotAddToSimpleContent()
static Exception DatasetConflictingName(string table)
static Exception ValueArrayLength()
static Exception InvalidRowBitPattern()
static Exception RowAlreadyDeleted()
static Exception EnforceConstraint()
static Exception CanNotSerializeDataTableHierarchy()
static Exception InvalidRowState(DataRowState state)
static Exception DuplicateTableName2(string table, string ns)
static Exception ArgumentOutOfRange(string paramName)
static Exception CanNotRemoteDataTable()
static Exception CannotChangeCaseLocale()
static Exception RowAlreadyInTheCollection()
static Exception RowAlreadyInOtherCollection()
static Exception CanNotSerializeDataTableWithEmptyName()
static Exception InvalidPrefix(string name)
static Exception MultipleTextOnlyColumns()
static Exception TraceExceptionWithoutRethrow(Exception e)
static Exception TableNotFound(string tableName)
static Exception InvalidSortString(string sort)
static Exception DataSetUnsupportedSchema(string ns)
static Exception TableForeignPrimaryKey()
static Exception InvalidRemotingFormat(SerializationFormat mode)
static Exception ArgumentNull(string paramName)
void AddRef()
Definition Index.cs:196
int RemoveRef()
Definition Index.cs:215
int FindRecord(int record)
Definition Index.cs:419
int GetRecord(int recordIndex)
Definition Index.cs:148
void Save(XmlWriter xmlw)
int ImportRecord(DataTable src, int record)
void SetRowCache(DataRow[] newRows)
int CopyRecord(DataTable src, int record, int copy)
void Clear(bool clearAll)
void FreeRecord(ref int record)
static IDisposable EnterRestrictedScope(DataSet dataSet)
static string GenUniqueColumnName(string proposedName, DataTable table)
Definition XMLSchema.cs:97
static bool IsMappedColumn(DataColumn c)
void Save(DataSet ds, XmlWriter xw)
static ? Delegate Remove(Delegate? source, Delegate? value)
Definition Delegate.cs:463
static ? Delegate Combine(Delegate? a, Delegate? b)
Definition Delegate.cs:379
static readonly EventArgs Empty
Definition EventArgs.cs:9
static void SuppressFinalize(object obj)
Definition GC.cs:202
Definition GC.cs:8
int IndexOf(string source, char value)
bool IsSuffix(string source, string suffix, CompareOptions options)
virtual CompareInfo CompareInfo
static CultureInfo CurrentCulture
static CultureInfo InvariantCulture
override bool Equals([NotNullWhen(true)] object? value)
static string Load_ReadOnlyDataModified
Definition SR.cs:662
Definition SR.cs:7
int GetHashCode(object obj)
static StringComparer Create(CultureInfo culture, bool ignoreCase)
static int CompareExchange(ref int location1, int value, int comparand)
static int Increment(ref int location)
static ? Type GetType(string typeName, bool throwOnError, bool ignoreCase)
Definition Type.cs:408
static ? XmlSchema Read(TextReader reader, ValidationEventHandler? validationEventHandler)
Definition XmlSchema.cs:432
static ? string EncodeName(string? name)
Definition XmlConvert.cs:37
static ? string DecodeName(string? name)
Definition XmlConvert.cs:55
static ? string EncodeLocalName(string? name)
Definition XmlConvert.cs:49
static readonly XmlQualifiedName Empty
string? GetAttribute(string name)
virtual void Skip()
Definition XmlReader.cs:532
virtual void ReadEndElement()
Definition XmlReader.cs:751
bool MoveToAttribute(string name)
virtual bool HasAttributes
Definition XmlReader.cs:124
virtual XmlNodeType MoveToContent()
Definition XmlReader.cs:604
XmlNodeType NodeType
Definition XmlReader.cs:62
virtual string Name
Definition XmlReader.cs:65
void Remove(IComponent? component)
delegate void PropertyChangedEventHandler(object? sender, PropertyChangedEventArgs e)
delegate void DataTableNewRowEventHandler(object sender, DataTableNewRowEventArgs e)
delegate void DataColumnChangeEventHandler(object sender, DataColumnChangeEventArgs e)
delegate void DataTableClearEventHandler(object sender, DataTableClearEventArgs e)
delegate void FillErrorEventHandler(object sender, FillErrorEventArgs e)
delegate void DataRowChangeEventHandler(object sender, DataRowChangeEventArgs e)
delegate void EventHandler(object? sender, EventArgs e)
Index GetSortIndex()
Definition DataKey.cs:184