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

◆ HandleConstraint()

void System.Data.XSDSchema.HandleConstraint ( XmlSchemaIdentityConstraint keyNode)
inlinepackage

Definition at line 1248 of file XSDSchema.cs.

1249 {
1250 string text = null;
1252 if (text == null || text.Length == 0)
1253 {
1254 throw ExceptionBuilder.MissingAttribute("name");
1255 }
1257 {
1258 throw ExceptionBuilder.DuplicateConstraintRead(text);
1259 }
1260 string tableName = GetTableName(keyNode);
1261 string msdataAttribute = GetMsdataAttribute(keyNode, "TableNamespace");
1263 if (tableSmart == null)
1264 {
1265 return;
1266 }
1267 _constraintNodes.Add(text, new ConstraintTable(tableSmart, keyNode));
1269 text = GetStringAttribute(keyNode, "ConstraintName", text);
1270 DataColumn[] array = BuildKey(keyNode, tableSmart);
1271 if (array.Length == 0)
1272 {
1273 return;
1274 }
1275 UniqueConstraint uniqueConstraint = (UniqueConstraint)array[0].Table.Constraints.FindConstraint(new UniqueConstraint(text, array));
1276 if (uniqueConstraint == null)
1277 {
1278 array[0].Table.Constraints.Add(text, array, booleanAttribute);
1279 SetExtProperties(array[0].Table.Constraints[text], keyNode.UnhandledAttributes);
1280 }
1281 else
1282 {
1283 array = uniqueConstraint.ColumnsReference;
1284 SetExtProperties(uniqueConstraint, keyNode.UnhandledAttributes);
1285 if (booleanAttribute)
1286 {
1287 array[0].Table.PrimaryKey = array;
1288 }
1289 }
1291 {
1292 for (int i = 0; i < array.Length; i++)
1293 {
1294 array[i].AllowDBNull = false;
1295 }
1296 }
1297 }
virtual bool ContainsKey(object key)
Definition Hashtable.cs:724
virtual void Add(object key, object? value)
Definition Hashtable.cs:676
DataTableCollection Tables
Definition DataSet.cs:396
DataTable GetTableSmart(string name, string ns)
Hashtable _constraintNodes
Definition XSDSchema.cs:43
string GetStringAttribute(XmlSchemaAnnotated element, string attrName, string defVal)
DataColumn[] BuildKey(XmlSchemaIdentityConstraint keyNode, DataTable table)
static void SetExtProperties(object instance, XmlAttribute[] attrs)
Definition XSDSchema.cs:282
static string GetMsdataAttribute(XmlSchemaAnnotated node, string ln)
Definition XSDSchema.cs:342
string GetTableName(XmlSchemaIdentityConstraint key)
bool GetBooleanAttribute(XmlSchemaAnnotated element, string attrName, bool defVal)
static ? string DecodeName(string? name)
Definition XmlConvert.cs:55

References System.Data.XSDSchema._constraintNodes, System.Data.XSDSchema._ds, System.Collections.Hashtable.Add(), System.array, System.Data.XSDSchema.BuildKey(), System.Collections.Hashtable.ContainsKey(), System.Xml.XmlConvert.DecodeName(), System.Data.ExceptionBuilder.DuplicateConstraintRead(), System.Data.XSDSchema.GetBooleanAttribute(), System.Data.XSDSchema.GetMsdataAttribute(), System.Data.XSDSchema.GetStringAttribute(), System.Data.XSDSchema.GetTableName(), System.Data.DataTableCollection.GetTableSmart(), System.Data.ExceptionBuilder.MissingAttribute(), System.Data.XSDSchema.SetExtProperties(), System.Data.DataSet.Tables, and System.text.