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

◆ OnColumnValueChanged()

void System.Xml.XmlDataDocument.OnColumnValueChanged ( DataRow row,
DataColumn col,
XmlBoundElement rowElement )
inlineprivate

Definition at line 1114 of file XmlDataDocument.cs.

1115 {
1116 if (!IsNotMapped(col))
1117 {
1118 object value = row[col];
1119 if (col.ColumnMapping == MappingType.SimpleContent && Convert.IsDBNull(value) && !rowElement.IsFoliated)
1120 {
1121 ForceFoliation(rowElement, ElementState.WeakFoliation);
1122 }
1123 else if (!IsFoliated(rowElement))
1124 {
1125 goto IL_0318;
1126 }
1127 if (IsTextOnly(col))
1128 {
1129 if (Convert.IsDBNull(value))
1130 {
1131 value = string.Empty;
1132 XmlAttribute attributeNode = rowElement.GetAttributeNode("xsi:nil");
1133 if (attributeNode == null)
1134 {
1135 attributeNode = CreateAttribute("xsi", "nil", "http://www.w3.org/2001/XMLSchema-instance");
1136 attributeNode.Value = "true";
1137 rowElement.SetAttributeNode(attributeNode);
1138 _bHasXSINIL = true;
1139 }
1140 else
1141 {
1142 attributeNode.Value = "true";
1143 }
1144 }
1145 else
1146 {
1147 XmlAttribute attributeNode2 = rowElement.GetAttributeNode("xsi:nil");
1148 if (attributeNode2 != null)
1149 {
1150 attributeNode2.Value = "false";
1151 }
1152 }
1153 ReplaceInitialChildText(rowElement, col.ConvertObjectToXml(value));
1154 }
1155 else
1156 {
1157 bool flag = false;
1158 if (col.ColumnMapping == MappingType.Attribute)
1159 {
1160 foreach (XmlAttribute attribute in rowElement.Attributes)
1161 {
1162 if (attribute.LocalName == col.EncodedColumnName && attribute.NamespaceURI == col.Namespace)
1163 {
1164 if (Convert.IsDBNull(value))
1165 {
1166 attribute.OwnerElement.Attributes.Remove(attribute);
1167 }
1168 else
1169 {
1170 attribute.Value = col.ConvertObjectToXml(value);
1171 }
1172 flag = true;
1173 break;
1174 }
1175 }
1176 if (!flag && !Convert.IsDBNull(value))
1177 {
1178 rowElement.SetAttribute(col.EncodedColumnName, col.Namespace, col.ConvertObjectToXml(value));
1179 }
1180 }
1181 else
1182 {
1183 RegionIterator regionIterator = new RegionIterator(rowElement);
1184 bool flag2 = regionIterator.Next();
1185 while (true)
1186 {
1187 if (flag2)
1188 {
1189 if (regionIterator.CurrentNode.NodeType == XmlNodeType.Element)
1190 {
1191 XmlElement xmlElement = (XmlElement)regionIterator.CurrentNode;
1192 if (xmlElement is XmlBoundElement { Row: not null })
1193 {
1194 flag2 = regionIterator.NextRight();
1195 continue;
1196 }
1197 if (xmlElement.LocalName == col.EncodedColumnName && xmlElement.NamespaceURI == col.Namespace)
1198 {
1199 flag = true;
1200 if (Convert.IsDBNull(value))
1201 {
1203 flag2 = regionIterator.NextRight();
1204 xmlElement.ParentNode.RemoveChild(xmlElement);
1205 continue;
1206 }
1207 ReplaceInitialChildText(xmlElement, col.ConvertObjectToXml(value));
1208 XmlAttribute attributeNode3 = xmlElement.GetAttributeNode("xsi:nil");
1209 if (attributeNode3 != null)
1210 {
1211 attributeNode3.Value = "false";
1212 }
1213 break;
1214 }
1215 }
1216 flag2 = regionIterator.Next();
1217 continue;
1218 }
1219 if (!flag && !Convert.IsDBNull(value))
1220 {
1221 XmlElement xmlElement2 = new XmlBoundElement(string.Empty, col.EncodedColumnName, col.Namespace, this);
1222 xmlElement2.AppendChild(CreateTextNode(col.ConvertObjectToXml(value)));
1224 if (columnInsertAfterLocation != null)
1225 {
1227 }
1228 else if (rowElement.FirstChild != null)
1229 {
1230 rowElement.InsertBefore(xmlElement2, rowElement.FirstChild);
1231 }
1232 else
1233 {
1234 rowElement.AppendChild(xmlElement2);
1235 }
1236 }
1237 break;
1238 }
1239 }
1240 }
1241 }
1242 goto IL_0318;
1243 IL_0318:
1245 if (nestedParentRelation != null && nestedParentRelation.ChildKey.ContainsColumn(col))
1246 {
1248 }
1249 }
bool ICollection< KeyValuePair< TKey, TValue > >. Remove(KeyValuePair< TKey, TValue > keyValuePair)
bool IsFoliated(XmlElement element)
void ReplaceInitialChildText(XmlNode parent, string value)
void ForceFoliation(XmlBoundElement node, ElementState newState)
void OnNestedParentChange(DataRow child, XmlBoundElement childElement, DataColumn childCol)
bool IsNotMapped(DataColumn c)
XmlNode GetColumnInsertAfterLocation(DataRow row, DataColumn col, XmlBoundElement rowElement)
static DataRelation GetNestedParentRelation(DataRow row)
bool IsTextOnly(DataColumn c)
void PromoteNonValueChildren(XmlNode parent)
virtual XmlText CreateTextNode(string? text)
XmlAttribute CreateAttribute(string name)

References System.Xml.XmlDataDocument._bHasXSINIL, System.Xml.XmlDocument.CreateAttribute(), System.Xml.XmlDocument.CreateTextNode(), System.Xml.Dictionary, System.Xml.XmlDataDocument.ForceFoliation(), System.Xml.XmlDataDocument.GetColumnInsertAfterLocation(), System.Xml.XmlDataDocument.GetNestedParentRelation(), System.Convert.IsDBNull(), System.Xml.XmlDataDocument.IsFoliated(), System.Xml.XmlDataDocument.IsNotMapped(), System.Xml.XmlDataDocument.IsTextOnly(), System.Xml.XmlDataDocument.OnNestedParentChange(), System.Xml.XmlDataDocument.PromoteNonValueChildren(), System.Collections.Generic.Dictionary< TKey, TValue >.Remove(), System.Xml.XmlDataDocument.ReplaceInitialChildText(), and System.value.

Referenced by System.Xml.XmlDataDocument.OnColumnChanged(), System.Xml.XmlDataDocument.OnColumnValuesChanged(), and System.Xml.XmlDataDocument.UpdateAllColumns().