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

◆ WritePrimitive()

void System.Xml.Serialization.XmlSerializationWriterILGen.WritePrimitive ( string method,
string name,
string ns,
object defaultValue,
SourceInfo source,
TypeMapping mapping,
bool writeXsiType,
bool isElement,
bool isNullable )
inlineprivate

Definition at line 171 of file XmlSerializationWriterILGen.cs.

172 {
173 TypeDesc typeDesc = mapping.TypeDesc;
174 bool flag = defaultValue != null && defaultValue != DBNull.Value && mapping.TypeDesc.HasDefaultSupport;
175 if (flag)
176 {
177 if (mapping is EnumMapping)
178 {
179 source.Load(mapping.TypeDesc.Type);
180 string text = null;
181 if (((EnumMapping)mapping).IsFlags)
182 {
183 string[] array = ((string)defaultValue).Split((char[]?)null);
184 for (int i = 0; i < array.Length; i++)
185 {
186 if (array[i] != null && array[i].Length != 0)
187 {
188 if (i > 0)
189 {
190 text += ", ";
191 }
192 text += array[i];
193 }
194 }
195 }
196 else
197 {
199 }
200 ilg.Ldc(Enum.Parse(mapping.TypeDesc.Type, text, ignoreCase: false));
201 ilg.If(Cmp.NotEqualTo);
202 }
203 else
204 {
206 }
207 }
208 List<Type> list = new List<Type>();
209 ilg.Ldarg(0);
210 list.Add(typeof(string));
212 if (ns != null)
213 {
214 list.Add(typeof(string));
216 }
218 if (mapping is EnumMapping)
219 {
221 list.Add(returnType);
222 }
223 else
224 {
226 list.Add(returnType);
227 }
228 if (writeXsiType)
229 {
230 list.Add(typeof(XmlQualifiedName));
231 ConstructorInfo constructor = typeof(XmlQualifiedName).GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, new Type[2]
232 {
233 typeof(string),
234 typeof(string)
235 });
236 ilg.Ldstr(GetCSharpString(mapping.TypeName));
237 ilg.Ldstr(GetCSharpString(mapping.Namespace));
239 }
240 MethodInfo method2 = typeof(XmlSerializationWriter).GetMethod(method, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, list.ToArray());
242 if (flag)
243 {
244 ilg.EndIf();
245 }
246 }
void Add(TKey key, TValue value)
void New(ConstructorInfo constructorInfo)
void Call(MethodInfo methodInfo)
void WriteCheckDefault(SourceInfo source, object value, bool isNullable)
void WriteEnumValue(EnumMapping mapping, SourceInfo source, out Type returnType)
void WritePrimitiveValue(TypeDesc typeDesc, SourceInfo source, out Type returnType)

References System.Collections.Generic.Dictionary< TKey, TValue >.Add(), System.array, System.Xml.Serialization.CodeGenerator.Call(), System.Xml.Dictionary, System.Xml.Serialization.CodeGenerator.EndIf(), System.Xml.Serialization.XmlSerializationILGen.GetCSharpString(), System.Xml.Serialization.CodeGenerator.If(), System.Xml.Serialization.XmlSerializationILGen.ilg, System.Xml.Serialization.CodeGenerator.Ldarg(), System.Xml.Serialization.CodeGenerator.Ldc(), System.Xml.Serialization.CodeGenerator.Ldstr(), System.Xml.Schema.Length, System.list, System.Xml.Serialization.CodeGenerator.New(), System.Enum.Parse(), System.source, System.text, System.Xml.Serialization.XmlSerializationWriterILGen.WriteCheckDefault(), System.Xml.Serialization.XmlSerializationWriterILGen.WriteEnumValue(), and System.Xml.Serialization.XmlSerializationWriterILGen.WritePrimitiveValue().

Referenced by System.Xml.Serialization.XmlSerializationWriterILGen.WriteAttribute(), and System.Xml.Serialization.XmlSerializationWriterILGen.WriteElement().