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

◆ EndElementIdentityConstraints()

void System.Xml.Schema.XmlSchemaValidator.EndElementIdentityConstraints ( object typedValue,
string stringValue,
XmlSchemaDatatype datatype )
inlineprivate

Definition at line 2153 of file XmlSchemaValidator.cs.

2154 {
2155 string localName = _context.LocalName;
2156 string @namespace = _context.Namespace;
2157 for (int num = _validationStack.Length - 1; num >= _startIDConstraint; num--)
2158 {
2159 if (((ValidationState)_validationStack[num]).Constr != null)
2160 {
2161 ConstraintStruct[] constr = ((ValidationState)_validationStack[num]).Constr;
2162 for (int i = 0; i < constr.Length; i++)
2163 {
2164 for (int j = 0; j < constr[i].axisFields.Count; j++)
2165 {
2166 LocatedActiveAxis locatedActiveAxis = (LocatedActiveAxis)constr[i].axisFields[j];
2167 if (locatedActiveAxis.isMatched)
2168 {
2169 locatedActiveAxis.isMatched = false;
2170 if (locatedActiveAxis.Ks[locatedActiveAxis.Column] != null)
2171 {
2172 SendValidationEvent(System.SR.Sch_FieldSingleValueExpected, localName);
2173 }
2175 {
2176 if (typedValue != null && stringValue.Length != 0)
2177 {
2178 locatedActiveAxis.Ks[locatedActiveAxis.Column] = new TypedObject(typedValue, stringValue, datatype);
2179 }
2180 }
2181 else if (typedValue != null)
2182 {
2183 locatedActiveAxis.Ks[locatedActiveAxis.Column] = new TypedObject(typedValue, stringValue, datatype);
2184 }
2185 }
2186 locatedActiveAxis.EndElement(localName, @namespace);
2187 }
2188 if (!constr[i].axisSelector.EndElement(localName, @namespace))
2189 {
2190 continue;
2191 }
2192 KeySequence keySequence = constr[i].axisSelector.PopKS();
2193 switch (constr[i].constraint.Role)
2194 {
2195 case CompiledIdentityConstraint.ConstraintRole.Key:
2196 if (!keySequence.IsQualified())
2197 {
2198 SendValidationEvent(new XmlSchemaValidationException(System.SR.Sch_MissingKey, constr[i].constraint.name.ToString(), _sourceUriString, keySequence.PosLine, keySequence.PosCol));
2199 }
2200 else if (constr[i].qualifiedTable.Contains(keySequence))
2201 {
2202 SendValidationEvent(new XmlSchemaValidationException(System.SR.Sch_DuplicateKey, new string[2]
2203 {
2204 keySequence.ToString(),
2205 constr[i].constraint.name.ToString()
2206 }, _sourceUriString, keySequence.PosLine, keySequence.PosCol));
2207 }
2208 else
2209 {
2210 constr[i].qualifiedTable.Add(keySequence, keySequence);
2211 }
2212 break;
2213 case CompiledIdentityConstraint.ConstraintRole.Unique:
2214 if (keySequence.IsQualified())
2215 {
2216 if (constr[i].qualifiedTable.Contains(keySequence))
2217 {
2218 SendValidationEvent(new XmlSchemaValidationException(System.SR.Sch_DuplicateKey, new string[2]
2219 {
2220 keySequence.ToString(),
2221 constr[i].constraint.name.ToString()
2222 }, _sourceUriString, keySequence.PosLine, keySequence.PosCol));
2223 }
2224 else
2225 {
2226 constr[i].qualifiedTable.Add(keySequence, keySequence);
2227 }
2228 }
2229 break;
2230 case CompiledIdentityConstraint.ConstraintRole.Keyref:
2231 if (constr[i].qualifiedTable != null && keySequence.IsQualified() && !constr[i].qualifiedTable.Contains(keySequence))
2232 {
2233 constr[i].qualifiedTable.Add(keySequence, keySequence);
2234 }
2235 break;
2236 }
2237 }
2238 }
2239 }
2240 ConstraintStruct[] constr2 = ((ValidationState)_validationStack[_validationStack.Length - 1]).Constr;
2241 if (constr2 == null)
2242 {
2243 return;
2244 }
2245 for (int k = 0; k < constr2.Length; k++)
2246 {
2247 if (constr2[k].constraint.Role == CompiledIdentityConstraint.ConstraintRole.Keyref || constr2[k].keyrefTable == null)
2248 {
2249 continue;
2250 }
2251 foreach (KeySequence key in constr2[k].keyrefTable.Keys)
2252 {
2253 if (!constr2[k].qualifiedTable.Contains(key))
2254 {
2255 SendValidationEvent(new XmlSchemaValidationException(System.SR.Sch_UnresolvedKeyref, new string[2]
2256 {
2257 key.ToString(),
2258 constr2[k].constraint.name.ToString()
2259 }, _sourceUriString, key.PosLine, key.PosCol));
2260 }
2261 }
2262 }
2263 }
bool ICollection< KeyValuePair< TKey, TValue > >. Contains(KeyValuePair< TKey, TValue > keyValuePair)
void Add(TKey key, TValue value)
static string Sch_UnresolvedKeyref
Definition SR.cs:732
static string Sch_MissingKey
Definition SR.cs:742
static string Sch_DuplicateKey
Definition SR.cs:744
static string Sch_FieldSingleValueExpected
Definition SR.cs:740
Definition SR.cs:7

References System.Xml.Schema.XmlSchemaValidator._context, System.Collections.Generic.Dictionary< TKey, TValue >.Add(), System.Collections.Generic.Dictionary< TKey, TValue >.Contains(), System.Collections.Generic.Dictionary< TKey, TValue >.Count, System.Xml.Dictionary, System.LocalAppContextSwitches.IgnoreEmptyKeySequences, System.key, System.Collections.Generic.Dictionary< TKey, TValue >.Keys, System.Xml.HWStack.Length, System.Xml.Schema.ValidationState.LocalName, System.SR.Sch_DuplicateKey, System.SR.Sch_FieldSingleValueExpected, System.SR.Sch_MissingKey, and System.SR.Sch_UnresolvedKeyref.

Referenced by System.Xml.Schema.XmlSchemaValidator.InternalValidateEndElement().