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

◆ HandleKeyref()

void System.Data.XSDSchema.HandleKeyref ( XmlSchemaKeyref keyref)
inlinepackage

Definition at line 1155 of file XSDSchema.cs.

1156 {
1157 string text = XmlConvert.DecodeName(keyref.Refer.Name);
1158 string defVal = XmlConvert.DecodeName(keyref.Name);
1159 defVal = GetStringAttribute(keyref, "ConstraintName", defVal);
1160 string tableName = GetTableName(keyref);
1161 string msdataAttribute = GetMsdataAttribute(keyref, "TableNamespace");
1163 if (tableSmart == null)
1164 {
1165 return;
1166 }
1167 if (text == null || text.Length == 0)
1168 {
1169 throw ExceptionBuilder.MissingRefer(defVal);
1170 }
1171 ConstraintTable constraintTable = (ConstraintTable)_constraintNodes[text];
1172 if (constraintTable == null)
1173 {
1174 throw ExceptionBuilder.InvalidKey(defVal);
1175 }
1176 DataColumn[] array = BuildKey(constraintTable.constraint, constraintTable.table);
1177 DataColumn[] array2 = BuildKey(keyref, tableSmart);
1178 ForeignKeyConstraint foreignKeyConstraint = null;
1179 if (GetBooleanAttribute(keyref, "ConstraintOnly", defVal: false))
1180 {
1181 int num = array2[0].Table.Constraints.InternalIndexOf(defVal);
1182 if (num > -1 && array2[0].Table.Constraints[num].ConstraintName != defVal)
1183 {
1184 num = -1;
1185 }
1186 if (num < 0)
1187 {
1188 foreignKeyConstraint = new ForeignKeyConstraint(defVal, array, array2);
1189 array2[0].Table.Constraints.Add(foreignKeyConstraint);
1190 }
1191 }
1192 else
1193 {
1194 string text2 = XmlConvert.DecodeName(GetStringAttribute(keyref, "RelationName", keyref.Name));
1195 if (text2 == null || text2.Length == 0)
1196 {
1197 text2 = defVal;
1198 }
1199 int num2 = array2[0].Table.DataSet.Relations.InternalIndexOf(text2);
1200 if (num2 > -1 && array2[0].Table.DataSet.Relations[num2].RelationName != text2)
1201 {
1202 num2 = -1;
1203 }
1204 DataRelation dataRelation = null;
1205 if (num2 < 0)
1206 {
1207 dataRelation = new DataRelation(text2, array, array2);
1208 SetExtProperties(dataRelation, keyref.UnhandledAttributes);
1209 array[0].Table.DataSet.Relations.Add(dataRelation);
1211 {
1212 _tableDictionary[dataRelation.ParentTable].Add(dataRelation.ChildTable);
1213 }
1214 foreignKeyConstraint = dataRelation.ChildKeyConstraint;
1216 }
1217 else
1218 {
1219 dataRelation = array2[0].Table.DataSet.Relations[num2];
1220 }
1221 if (GetBooleanAttribute(keyref, "IsNested", defVal: false))
1222 {
1223 dataRelation.Nested = true;
1224 }
1225 }
1226 string msdataAttribute2 = GetMsdataAttribute(keyref, "AcceptRejectRule");
1227 string msdataAttribute3 = GetMsdataAttribute(keyref, "UpdateRule");
1228 string msdataAttribute4 = GetMsdataAttribute(keyref, "DeleteRule");
1229 if (foreignKeyConstraint != null)
1230 {
1231 if (msdataAttribute2 != null)
1232 {
1234 }
1235 if (msdataAttribute3 != null)
1236 {
1238 }
1239 if (msdataAttribute4 != null)
1240 {
1242 }
1243 SetExtProperties(foreignKeyConstraint, keyref.UnhandledAttributes);
1244 }
1245 }
void Add(TKey key, TValue value)
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)
Dictionary< DataTable, List< DataTable > > _tableDictionary
Definition XSDSchema.cs:63
static void SetExtProperties(object instance, XmlAttribute[] attrs)
Definition XSDSchema.cs:282
static string GetMsdataAttribute(XmlSchemaAnnotated node, string ln)
Definition XSDSchema.cs:342
static AcceptRejectRule TranslateAcceptRejectRule(string strRule)
string GetTableName(XmlSchemaIdentityConstraint key)
bool GetBooleanAttribute(XmlSchemaAnnotated element, string attrName, bool defVal)
static Rule TranslateRule(string strRule)
static ? string DecodeName(string? name)
Definition XmlConvert.cs:55

References System.Data.XSDSchema._constraintNodes, System.Data.XSDSchema._ds, System.Data.XSDSchema._tableDictionary, System.Collections.Generic.Dictionary< TKey, TValue >.Add(), System.array, System.Data.XSDSchema.BuildKey(), System.Collections.Generic.Dictionary< TKey, TValue >.ContainsKey(), System.Xml.XmlConvert.DecodeName(), System.Xml.Dictionary, System.Data.XSDSchema.FromInference, System.Data.XSDSchema.GetBooleanAttribute(), System.Data.XSDSchema.GetMsdataAttribute(), System.Data.XSDSchema.GetStringAttribute(), System.Data.XSDSchema.GetTableName(), System.Data.DataTableCollection.GetTableSmart(), System.Data.ExceptionBuilder.InvalidKey(), System.Data.ExceptionBuilder.MissingRefer(), System.Data.XSDSchema.SetExtProperties(), System.Data.DataSet.Tables, System.text, System.Data.XSDSchema.TranslateAcceptRejectRule(), and System.Data.XSDSchema.TranslateRule().