2 writes to _ilg
System.Private.DataContractSerialization (2)
System\Runtime\Serialization\XmlFormatWriterGenerator.cs (2)
82
_ilg
= new CodeGenerator();
126
_ilg
= new CodeGenerator();
185 references to _ilg
System.Private.DataContractSerialization (185)
System\Runtime\Serialization\XmlFormatWriterGenerator.cs (185)
86
_ilg
.BeginMethod("Write" + classContract.XmlName.Name + "ToXml", Globals.TypeOfXmlFormatClassWriterDelegate, memberAccessFlag);
105
return (XmlFormatClassWriterDelegate)
_ilg
.EndMethod();
130
_ilg
.BeginMethod("Write" + collectionContract.XmlName.Name + "ToXml", Globals.TypeOfXmlFormatCollectionWriterDelegate, memberAccessFlag);
149
return (XmlFormatCollectionWriterDelegate)
_ilg
.EndMethod();
156
_xmlWriterArg =
_ilg
.GetArg(0);
157
_contextArg =
_ilg
.GetArg(2);
158
_dataContractArg =
_ilg
.GetArg(3);
160
_objectLocal =
_ilg
.DeclareLocal(objType);
161
ArgBuilder objectArg =
_ilg
.GetArg(1);
162
_ilg
.Load(objectArg);
170
_ilg
.ConvertValue(objectArg.ArgType, Globals.TypeOfDateTimeOffset);
171
_ilg
.Call(XmlFormatGeneratorStatics.GetDateTimeOffsetAdapterMethod);
175
_ilg
.ConvertValue(objectArg.ArgType, Globals.TypeOfMemoryStream);
176
_ilg
.Call(XmlFormatGeneratorStatics.GetMemoryStreamAdapterMethod);
180
_ilg
.ConvertValue(objectArg.ArgType, objType);
182
_ilg
.Stloc(_objectLocal);
197
_ilg
.Load(_contextArg);
198
_ilg
.LoadMember(XmlFormatGeneratorStatics.SerializeReadOnlyTypesProperty);
199
_ilg
.IfNot();
200
_ilg
.Load(_dataContractArg);
201
_ilg
.LoadMember(serializationExceptionMessageProperty);
202
_ilg
.Load(null);
203
_ilg
.Call(XmlFormatGeneratorStatics.ThrowInvalidDataContractExceptionMethod);
204
_ilg
.EndIf();
213
_ilg
.LoadAddress(_objectLocal);
214
_ilg
.Load(_contextArg);
215
_ilg
.Call(XmlFormatGeneratorStatics.GetStreamingContextMethod);
216
_ilg
.Call(classContract.OnSerializing);
226
_ilg
.LoadAddress(_objectLocal);
227
_ilg
.Load(_contextArg);
228
_ilg
.Call(XmlFormatGeneratorStatics.GetStreamingContextMethod);
229
_ilg
.Call(classContract.OnSerialized);
241
_ilg
.Call(_contextArg, XmlFormatGeneratorStatics.WriteISerializableMethod, _xmlWriterArg, _objectLocal);
247
_contractNamespacesLocal =
_ilg
.DeclareLocal(typeof(XmlDictionaryString[]));
248
_ilg
.Load(_dataContractArg);
249
_ilg
.LoadMember(XmlFormatGeneratorStatics.ContractNamespacesField);
250
_ilg
.Store(_contractNamespacesLocal);
253
_memberNamesLocal =
_ilg
.DeclareLocal(typeof(XmlDictionaryString[]));
254
_ilg
.Load(_dataContractArg);
255
_ilg
.LoadMember(XmlFormatGeneratorStatics.MemberNamesField);
256
_ilg
.Store(_memberNamesLocal);
262
_childElementNamespacesLocal =
_ilg
.DeclareLocal(typeof(XmlDictionaryString[]));
263
_ilg
.Load(_dataContractArg);
264
_ilg
.LoadMember(XmlFormatGeneratorStatics.ChildElementNamespacesProperty);
265
_ilg
.Store(_childElementNamespacesLocal);
271
LocalBuilder extensionDataLocal =
_ilg
.DeclareLocal(Globals.TypeOfExtensionDataObject);
272
_ilg
.Load(_objectLocal);
273
_ilg
.ConvertValue(_objectLocal.LocalType, Globals.TypeOfIExtensibleDataObject);
274
_ilg
.LoadMember(XmlFormatGeneratorStatics.ExtensionDataProperty);
275
_ilg
.Store(extensionDataLocal);
276
_ilg
.Call(_contextArg, XmlFormatGeneratorStatics.WriteExtensionDataMethod, _xmlWriterArg, extensionDataLocal, -1);
294
LocalBuilder namespaceLocal =
_ilg
.DeclareLocal(typeof(XmlDictionaryString));
297
_ilg
.Load(_dataContractArg);
298
_ilg
.LoadMember(XmlFormatGeneratorStatics.NamespaceProperty);
302
_ilg
.LoadArrayElement(_contractNamespacesLocal, _typeIndex - 1);
305
_ilg
.Store(namespaceLocal);
308
_ilg
.Call(thisObj: _contextArg, XmlFormatGeneratorStatics.IncrementItemCountMethod, classMemberCount);
316
_ilg
.Load(_contextArg);
317
_ilg
.Call(methodInfo: member.IsGetOnlyCollection ?
324
_ilg
.IfNotDefaultValue(memberValue);
332
_ilg
.Load(_xmlWriterArg);
333
_ilg
.LoadArrayElement(_childElementNamespacesLocal!, i + _childElementIndex);
334
_ilg
.Call(methodInfo: XmlFormatGeneratorStatics.WriteNamespaceDeclMethod);
344
_ilg
.Call(thisObj: _contextArg, XmlFormatGeneratorStatics.WriteExtensionDataMethod, _xmlWriterArg, extensionDataLocal, memberCount);
351
_ilg
.Else();
352
_ilg
.Call(thisObj: null, XmlFormatGeneratorStatics.ThrowRequiredMemberMustBeEmittedMethod, member.Name, classContract.UnderlyingType);
354
_ilg
.EndIf();
365
_ilg
.LoadAddress(_objectLocal);
366
_ilg
.LoadMember(member.MemberInfo);
367
LocalBuilder memberValue =
_ilg
.DeclareLocal(member.MemberType);
368
_ilg
.Stloc(memberValue);
376
LocalBuilder itemNamespace =
_ilg
.DeclareLocal(typeof(XmlDictionaryString));
377
_ilg
.Load(_dataContractArg);
378
_ilg
.LoadMember(XmlFormatGeneratorStatics.NamespaceProperty);
379
_ilg
.Store(itemNamespace);
381
LocalBuilder itemName =
_ilg
.DeclareLocal(typeof(XmlDictionaryString));
382
_ilg
.Load(_dataContractArg);
383
_ilg
.LoadMember(XmlFormatGeneratorStatics.CollectionItemNameProperty);
384
_ilg
.Store(itemName);
388
_ilg
.Load(_xmlWriterArg);
389
_ilg
.Load(_dataContractArg);
390
_ilg
.LoadMember(XmlFormatGeneratorStatics.ChildElementNamespaceProperty);
391
_ilg
.Call(XmlFormatGeneratorStatics.WriteNamespaceDeclMethod);
397
LocalBuilder i =
_ilg
.DeclareLocal(Globals.TypeOfInt);
399
_ilg
.Call(_contextArg, XmlFormatGeneratorStatics.IncrementArrayCountMethod, _xmlWriterArg, _objectLocal);
403
_ilg
.For(i, 0, _objectLocal);
407
_ilg
.LoadArrayElement(_objectLocal, i);
408
LocalBuilder memberValue =
_ilg
.DeclareLocal(itemType);
409
_ilg
.Stloc(memberValue);
413
_ilg
.EndFor();
438
_ilg
.Call(_contextArg, incrementCollectionCountMethod, _xmlWriterArg, _objectLocal);
493
LocalBuilder currentValue =
_ilg
.DeclareLocal(elementType);
495
LocalBuilder enumerator =
_ilg
.DeclareLocal(enumeratorType);
496
_ilg
.Call(_objectLocal, collectionContract.GetEnumeratorMethod);
499
_ilg
.ConvertValue(collectionContract.GetEnumeratorMethod.ReturnType, Globals.TypeOfIDictionaryEnumerator);
500
_ilg
.New(XmlFormatGeneratorStatics.DictionaryEnumeratorCtor);
506
_ilg
.ConvertValue(collectionContract.GetEnumeratorMethod.ReturnType, ctorParam);
507
_ilg
.New(dictEnumCtor);
509
_ilg
.Stloc(enumerator);
511
_ilg
.ForEach(currentValue, elementType, enumerator, getCurrentMethod);
514
_ilg
.Call(_contextArg, XmlFormatGeneratorStatics.IncrementItemCountMethod, 1);
522
_ilg
.Call(_dataContractArg, XmlFormatGeneratorStatics.GetItemContractMethod);
523
_ilg
.Load(_xmlWriterArg);
524
_ilg
.Load(currentValue);
525
_ilg
.ConvertValue(currentValue.LocalType, Globals.TypeOfObject);
526
_ilg
.Load(_contextArg);
527
_ilg
.Call(XmlFormatGeneratorStatics.WriteXmlValueMethod);
535
_ilg
.EndForEach(moveNextMethod);
550
_ilg
.Load(_xmlWriterArg);
554
_ilg
.Load(_contextArg);
555
_ilg
.Load(_xmlWriterArg);
560
_ilg
.Load(value);
564
_ilg
.LoadAddress(_objectLocal);
565
_ilg
.LoadMember(memberInfo);
569
_ilg
.LoadArrayElement(_objectLocal, arrayItemIndex);
574
_ilg
.Load(name);
578
_ilg
.LoadArrayElement(_memberNamesLocal!, nameIndex);
581
_ilg
.Load(ns);
583
_ilg
.Call(primitiveContract.XmlFormatWriterMethod);
624
_ilg
.Load(_xmlWriterArg);
625
_ilg
.Load(value);
626
_ilg
.Load(itemName);
627
_ilg
.Load(itemNamespace);
628
_ilg
.Call(typeof(XmlWriterDelegator).GetMethod(writeArrayMethod, Globals.ScanAllMembers, new Type[] { type, typeof(XmlDictionaryString), typeof(XmlDictionaryString) })!);
641
_ilg
.Load(memberValue);
642
_ilg
.Load(memberType);
643
_ilg
.Call(XmlFormatGeneratorStatics.BoxPointer);
645
memberValue =
_ilg
.DeclareLocal(memberType);
646
_ilg
.Store(memberValue);
654
_ilg
.Call(_xmlWriterArg, primitiveContract.XmlFormatContentWriterMethod, memberValue);
667
_ilg
.Load(memberValue);
668
_ilg
.Load(null);
669
_ilg
.Ceq();
671
_ilg
.If();
672
_ilg
.Call(_contextArg, XmlFormatGeneratorStatics.WriteNullMethod, _xmlWriterArg, memberType, DataContract.IsTypeSerializable(memberType));
673
_ilg
.Else();
679
_ilg
.Call(_xmlWriterArg, primitiveContract.XmlFormatContentWriterMethod, memberValue);
683
_ilg
.Call(_contextArg, primitiveContract.XmlFormatContentWriterMethod, _xmlWriterArg, memberValue);
692
_ilg
.Load(memberValue);
693
_ilg
.ConvertValue(memberValue.LocalType, Globals.TypeOfObject);
694
memberValue =
_ilg
.DeclareLocal(Globals.TypeOfObject);
696
_ilg
.Stloc(memberValue);
697
_ilg
.If(memberValue, Cmp.EqualTo, null);
698
_ilg
.Call(_contextArg, XmlFormatGeneratorStatics.WriteNullMethod, _xmlWriterArg, memberType, DataContract.IsTypeSerializable(memberType));
699
_ilg
.Else();
705
_ilg
.EndIf();
707
_ilg
.EndIf();
713
_ilg
.Load(_contextArg);
714
_ilg
.Load(_xmlWriterArg);
715
_ilg
.Load(memberValue);
716
_ilg
.ConvertValue(memberValue.LocalType, Globals.TypeOfObject);
717
LocalBuilder typeHandleValue =
_ilg
.DeclareLocal(typeof(RuntimeTypeHandle));
718
_ilg
.Call(null, typeof(Type).GetMethod("GetTypeHandle")!, memberValue);
719
_ilg
.Stloc(typeHandleValue);
720
_ilg
.LoadAddress(typeHandleValue);
721
_ilg
.Ldtoken(memberType);
722
_ilg
.Call(typeof(RuntimeTypeHandle).GetMethod("Equals", new Type[] { typeof(RuntimeTypeHandle) })!);
723
_ilg
.Load(writeXsiType);
724
_ilg
.Load(DataContract.GetId(memberType.TypeHandle));
725
_ilg
.Ldtoken(memberType);
726
_ilg
.Call(methodInfo);
735
Label onNull =
_ilg
.DefineLabel();
736
Label end =
_ilg
.DefineLabel();
737
_ilg
.Load(memberValue);
741
_ilg
.Dup();
742
_ilg
.Call(XmlFormatGeneratorStatics.GetHasValueMethod.MakeGenericMethod(innerType));
743
_ilg
.Brfalse(onNull);
744
_ilg
.Call(XmlFormatGeneratorStatics.GetNullableValueMethod.MakeGenericMethod(innerType));
747
memberValue =
_ilg
.DeclareLocal(memberType);
748
_ilg
.Stloc(memberValue);
749
_ilg
.Load(false); //isNull
750
_ilg
.Br(end);
751
_ilg
.MarkLabel(onNull);
752
_ilg
.Pop();
753
_ilg
.Call(XmlFormatGeneratorStatics.GetDefaultValueMethod.MakeGenericMethod(memberType));
754
_ilg
.Stloc(memberValue);
755
_ilg
.Load(true); //isNull
756
_ilg
.MarkLabel(end);
768
_ilg
.Load(_xmlWriterArg);
771
_ilg
.Load(Globals.ElementPrefix);
775
_ilg
.LoadArrayElement(_memberNamesLocal!, nameIndex);
777
_ilg
.Load(nameLocal);
780
_ilg
.Load(namespaceLocal);
782
_ilg
.Call(needsPrefix ? XmlFormatGeneratorStatics.WriteStartElementMethod3 : XmlFormatGeneratorStatics.WriteStartElementMethod2);
787
_ilg
.Call(_xmlWriterArg, XmlFormatGeneratorStatics.WriteEndElementMethod);