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

◆ WriteElements()

void System.Xml.Serialization.ReflectionXmlSerializationWriter.WriteElements ( object o,
object enumSource,
ElementAccessor[] elements,
TextAccessor text,
ChoiceIdentifierAccessor choice,
bool writeAccessors,
bool isNullable )
inlineprivate

Definition at line 161 of file ReflectionXmlSerializationWriter.cs.

162 {
163 if (elements.Length == 0 && text == null)
164 {
165 return;
166 }
167 if (elements.Length == 1 && text == null)
168 {
169 WriteElement(o, elements[0], writeAccessors);
170 }
171 else
172 {
173 if (isNullable && choice == null && o == null)
174 {
175 return;
176 }
177 int num = 0;
179 ElementAccessor elementAccessor = null;
180 foreach (ElementAccessor elementAccessor2 in elements)
181 {
182 if (elementAccessor2.Any)
183 {
184 num++;
185 if (elementAccessor2.Name != null && elementAccessor2.Name.Length > 0)
186 {
188 }
189 else if (elementAccessor == null)
190 {
192 }
193 }
194 else if (choice != null)
195 {
196 if (o != null && o.GetType() == elementAccessor2.Mapping.TypeDesc.Type)
197 {
199 return;
200 }
201 }
202 else
203 {
204 TypeDesc typeDesc = (elementAccessor2.IsUnbounded ? elementAccessor2.Mapping.TypeDesc.CreateArrayTypeDesc() : elementAccessor2.Mapping.TypeDesc);
205 if (o.GetType() == typeDesc.Type)
206 {
208 return;
209 }
210 }
211 }
212 if (num > 0 && o is XmlElement xmlElement)
213 {
214 foreach (ElementAccessor item in list)
215 {
216 if (item.Name == xmlElement.Name && item.Namespace == xmlElement.NamespaceURI)
217 {
219 return;
220 }
221 }
222 if (choice != null)
223 {
224 throw CreateChoiceIdentifierValueException(choice.Mapping.TypeDesc.FullName, choice.MemberName, xmlElement.Name, xmlElement.NamespaceURI);
225 }
226 if (elementAccessor == null)
227 {
229 }
231 }
232 else if (text != null)
233 {
234 WriteText(o, text);
235 }
236 else if (elements.Length != 0 && o != null)
237 {
239 }
240 }
241 }
void WriteElement(object o, ElementAccessor element, bool writeAccessor)
Exception CreateUnknownAnyElementException(string name, string ns)
Exception CreateChoiceIdentifierValueException(string value, string identifier, string name, string ns)

References System.Collections.Generic.Dictionary< TKey, TValue >.Add(), System.Xml.Serialization.XmlSerializationWriter.CreateChoiceIdentifierValueException(), System.Xml.Serialization.XmlSerializationWriter.CreateUnknownAnyElementException(), System.Xml.Serialization.XmlSerializationWriter.CreateUnknownTypeException(), System.Xml.Dictionary, System.item, System.list, System.text, System.Xml.Serialization.ReflectionXmlSerializationWriter.WriteElement(), and System.Xml.Serialization.ReflectionXmlSerializationWriter.WriteText().

Referenced by System.Xml.Serialization.ReflectionXmlSerializationWriter.WriteArrayItems(), and System.Xml.Serialization.ReflectionXmlSerializationWriter.WriteMember().