2 writes to ilg
System.Runtime.Serialization (2)
System\Runtime\Serialization\XmlFormatWriterGenerator.cs (2)
104
ilg
= new CodeGenerator();
134
ilg
= new CodeGenerator();
185 references to ilg
System.Runtime.Serialization (185)
System\Runtime\Serialization\XmlFormatWriterGenerator.cs (185)
108
ilg
.BeginMethod("Write" + classContract.StableName.Name + "ToXml", Globals.TypeOfXmlFormatClassWriterDelegate, memberAccessFlag);
129
return (XmlFormatClassWriterDelegate)
ilg
.EndMethod();
138
ilg
.BeginMethod("Write" + collectionContract.StableName.Name + "ToXml", Globals.TypeOfXmlFormatCollectionWriterDelegate, memberAccessFlag);
158
return (XmlFormatCollectionWriterDelegate)
ilg
.EndMethod();
163
xmlWriterArg =
ilg
.GetArg(0);
164
contextArg =
ilg
.GetArg(2);
165
dataContractArg =
ilg
.GetArg(3);
167
objectLocal =
ilg
.DeclareLocal(objType, "objSerialized");
168
ArgBuilder objectArg =
ilg
.GetArg(1);
169
ilg
.Load(objectArg);
177
ilg
.ConvertValue(objectArg.ArgType, Globals.TypeOfDateTimeOffset);
178
ilg
.Call(XmlFormatGeneratorStatics.GetDateTimeOffsetAdapterMethod);
182
ilg
.ConvertValue(objectArg.ArgType, objType);
184
ilg
.Stloc(objectLocal);
191
ilg
.Call(contextArg, XmlFormatGeneratorStatics.DemandMemberAccessPermissionMethod);
199
ilg
.Call(contextArg, XmlFormatGeneratorStatics.DemandSerializationFormatterPermissionMethod);
215
ilg
.Load(contextArg);
216
ilg
.LoadMember(XmlFormatGeneratorStatics.SerializeReadOnlyTypesProperty);
217
ilg
.IfNot();
218
ilg
.Load(dataContractArg);
219
ilg
.LoadMember(serializationExceptionMessageProperty);
220
ilg
.Load(null);
221
ilg
.Call(XmlFormatGeneratorStatics.ThrowInvalidDataContractExceptionMethod);
222
ilg
.EndIf();
231
ilg
.LoadAddress(objectLocal);
232
ilg
.Load(contextArg);
233
ilg
.Call(XmlFormatGeneratorStatics.GetStreamingContextMethod);
234
ilg
.Call(classContract.OnSerializing);
244
ilg
.LoadAddress(objectLocal);
245
ilg
.Load(contextArg);
246
ilg
.Call(XmlFormatGeneratorStatics.GetStreamingContextMethod);
247
ilg
.Call(classContract.OnSerialized);
256
ilg
.Call(contextArg, XmlFormatGeneratorStatics.WriteISerializableMethod, xmlWriterArg, objectLocal);
261
contractNamespacesLocal =
ilg
.DeclareLocal(typeof(XmlDictionaryString[]), "contractNamespaces");
262
ilg
.Load(dataContractArg);
263
ilg
.LoadMember(XmlFormatGeneratorStatics.ContractNamespacesField);
264
ilg
.Store(contractNamespacesLocal);
267
memberNamesLocal =
ilg
.DeclareLocal(typeof(XmlDictionaryString[]), "memberNames");
268
ilg
.Load(dataContractArg);
269
ilg
.LoadMember(XmlFormatGeneratorStatics.MemberNamesField);
270
ilg
.Store(memberNamesLocal);
276
childElementNamespacesLocal =
ilg
.DeclareLocal(typeof(XmlDictionaryString[]), "childElementNamespaces");
277
ilg
.Load(dataContractArg);
278
ilg
.LoadMember(XmlFormatGeneratorStatics.ChildElementNamespacesProperty);
279
ilg
.Store(childElementNamespacesLocal);
285
LocalBuilder extensionDataLocal =
ilg
.DeclareLocal(Globals.TypeOfExtensionDataObject, "extensionData");
286
ilg
.Load(objectLocal);
287
ilg
.ConvertValue(objectLocal.LocalType, Globals.TypeOfIExtensibleDataObject);
288
ilg
.LoadMember(XmlFormatGeneratorStatics.ExtensionDataProperty);
289
ilg
.Store(extensionDataLocal);
290
ilg
.Call(contextArg, XmlFormatGeneratorStatics.WriteExtensionDataMethod, xmlWriterArg, extensionDataLocal, -1);
304
LocalBuilder namespaceLocal =
ilg
.DeclareLocal(typeof(XmlDictionaryString), "ns");
307
ilg
.Load(dataContractArg);
308
ilg
.LoadMember(XmlFormatGeneratorStatics.NamespaceProperty);
311
ilg
.LoadArrayElement(contractNamespacesLocal, typeIndex - 1);
312
ilg
.Store(namespaceLocal);
314
ilg
.Call(contextArg, XmlFormatGeneratorStatics.IncrementItemCountMethod, classContract.Members.Count);
323
ilg
.Load(contextArg);
324
ilg
.Call(XmlFormatGeneratorStatics.StoreIsGetOnlyCollectionMethod);
329
ilg
.IfNotDefaultValue(memberValue);
337
ilg
.Load(xmlWriterArg);
338
ilg
.LoadArrayElement(childElementNamespacesLocal, i + childElementIndex);
339
ilg
.Call(XmlFormatGeneratorStatics.WriteNamespaceDeclMethod);
347
ilg
.Call(contextArg, XmlFormatGeneratorStatics.WriteExtensionDataMethod, xmlWriterArg, extensionDataLocal, memberCount);
352
ilg
.Else();
353
ilg
.Call(null, XmlFormatGeneratorStatics.ThrowRequiredMemberMustBeEmittedMethod, member.Name, classContract.UnderlyingType);
355
ilg
.EndIf();
367
ilg
.LoadAddress(objectLocal);
368
ilg
.LoadMember(member.MemberInfo);
369
LocalBuilder memberValue =
ilg
.DeclareLocal(member.MemberType, member.Name + "Value");
370
ilg
.Stloc(memberValue);
376
LocalBuilder itemNamespace =
ilg
.DeclareLocal(typeof(XmlDictionaryString), "itemNamespace");
377
ilg
.Load(dataContractArg);
378
ilg
.LoadMember(XmlFormatGeneratorStatics.NamespaceProperty);
379
ilg
.Store(itemNamespace);
381
LocalBuilder itemName =
ilg
.DeclareLocal(typeof(XmlDictionaryString), "itemName");
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, "i");
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, "memberValue");
409
ilg
.Stloc(memberValue);
413
ilg
.EndFor();
436
ilg
.Call(contextArg, incrementCollectionCountMethod, xmlWriterArg, objectLocal);
494
LocalBuilder currentValue =
ilg
.DeclareLocal(elementType, "currentValue");
496
LocalBuilder enumerator =
ilg
.DeclareLocal(enumeratorType, "enumerator");
497
ilg
.Call(objectLocal, collectionContract.GetEnumeratorMethod);
500
ilg
.ConvertValue(collectionContract.GetEnumeratorMethod.ReturnType, Globals.TypeOfIDictionaryEnumerator);
501
ilg
.New(XmlFormatGeneratorStatics.DictionaryEnumeratorCtor);
507
ilg
.ConvertValue(collectionContract.GetEnumeratorMethod.ReturnType, ctorParam);
508
ilg
.New(dictEnumCtor);
510
ilg
.Stloc(enumerator);
512
ilg
.ForEach(currentValue, elementType, enumeratorType, enumerator, getCurrentMethod);
515
ilg
.Call(contextArg, XmlFormatGeneratorStatics.IncrementItemCountMethod, 1);
523
ilg
.Call(dataContractArg, XmlFormatGeneratorStatics.GetItemContractMethod);
524
ilg
.Load(xmlWriterArg);
525
ilg
.Load(currentValue);
526
ilg
.ConvertValue(currentValue.LocalType, Globals.TypeOfObject);
527
ilg
.Load(contextArg);
528
ilg
.Call(XmlFormatGeneratorStatics.WriteXmlValueMethod);
536
ilg
.EndForEach(moveNextMethod);
549
ilg
.Load(xmlWriterArg);
553
ilg
.Load(contextArg);
554
ilg
.Load(xmlWriterArg);
559
ilg
.Load(value);
563
ilg
.LoadAddress(objectLocal);
564
ilg
.LoadMember(memberInfo);
568
ilg
.LoadArrayElement(objectLocal, arrayItemIndex);
573
ilg
.Load(name);
577
ilg
.LoadArrayElement(memberNamesLocal, nameIndex);
580
ilg
.Load(ns);
582
ilg
.Call(primitiveContract.XmlFormatWriterMethod);
621
ilg
.Load(xmlWriterArg);
622
ilg
.Load(value);
623
ilg
.Load(itemName);
624
ilg
.Load(itemNamespace);
625
ilg
.Call(typeof(XmlWriterDelegator).GetMethod(writeArrayMethod, Globals.ScanAllMembers, null, new Type[] { type, typeof(XmlDictionaryString), typeof(XmlDictionaryString) }, null));
636
ilg
.Load(memberValue);
637
ilg
.Load(memberType);
638
ilg
.Call(XmlFormatGeneratorStatics.BoxPointer);
640
memberValue =
ilg
.DeclareLocal(memberType, "memberValueRefPointer");
641
ilg
.Store(memberValue);
649
ilg
.Call(xmlWriterArg, primitiveContract.XmlFormatContentWriterMethod, memberValue);
662
ilg
.Load(memberValue);
663
ilg
.Load(null);
664
ilg
.Ceq();
666
ilg
.If();
667
ilg
.Call(contextArg, XmlFormatGeneratorStatics.WriteNullMethod, xmlWriterArg, memberType, DataContract.IsTypeSerializable(memberType));
668
ilg
.Else();
674
ilg
.Call(xmlWriterArg, primitiveContract.XmlFormatContentWriterMethod, memberValue);
678
ilg
.Call(contextArg, primitiveContract.XmlFormatContentWriterMethod, xmlWriterArg, memberValue);
687
ilg
.Load(memberValue);
688
ilg
.ConvertValue(memberValue.LocalType, Globals.TypeOfObject);
689
memberValue =
ilg
.DeclareLocal(Globals.TypeOfObject, "unwrappedMemberValue");
691
ilg
.Stloc(memberValue);
692
ilg
.If(memberValue, Cmp.EqualTo, null);
693
ilg
.Call(contextArg, XmlFormatGeneratorStatics.WriteNullMethod, xmlWriterArg, memberType, DataContract.IsTypeSerializable(memberType));
694
ilg
.Else();
700
ilg
.EndIf();
702
ilg
.EndIf();
708
ilg
.Load(contextArg);
709
ilg
.Load(xmlWriterArg);
710
ilg
.Load(memberValue);
711
ilg
.ConvertValue(memberValue.LocalType, Globals.TypeOfObject);
712
LocalBuilder typeHandleValue =
ilg
.DeclareLocal(typeof(RuntimeTypeHandle), "typeHandleValue");
713
ilg
.Call(null, typeof(Type).GetMethod("GetTypeHandle"), memberValue);
714
ilg
.Stloc(typeHandleValue);
715
ilg
.LoadAddress(typeHandleValue);
716
ilg
.Ldtoken(memberType);
717
ilg
.Call(typeof(RuntimeTypeHandle).GetMethod("Equals", new Type[] { typeof(RuntimeTypeHandle) }));
718
ilg
.Load(writeXsiType);
719
ilg
.Load(DataContract.GetId(memberType.TypeHandle));
720
ilg
.Ldtoken(memberType);
721
ilg
.Call(methodInfo);
728
Label onNull =
ilg
.DefineLabel();
729
Label end =
ilg
.DefineLabel();
730
ilg
.Load(memberValue);
734
ilg
.Dup();
735
ilg
.Call(XmlFormatGeneratorStatics.GetHasValueMethod.MakeGenericMethod(innerType));
736
ilg
.Brfalse(onNull);
737
ilg
.Call(XmlFormatGeneratorStatics.GetNullableValueMethod.MakeGenericMethod(innerType));
740
memberValue =
ilg
.DeclareLocal(memberType, "nullableUnwrappedMemberValue");
741
ilg
.Stloc(memberValue);
742
ilg
.Load(false); //isNull
743
ilg
.Br(end);
744
ilg
.MarkLabel(onNull);
745
ilg
.Pop();
746
ilg
.Call(XmlFormatGeneratorStatics.GetDefaultValueMethod.MakeGenericMethod(memberType));
747
ilg
.Stloc(memberValue);
748
ilg
.Load(true); //isNull
749
ilg
.MarkLabel(end);
761
ilg
.Load(xmlWriterArg);
764
ilg
.Load(Globals.ElementPrefix);
768
ilg
.LoadArrayElement(memberNamesLocal, nameIndex);
770
ilg
.Load(nameLocal);
773
ilg
.Load(namespaceLocal);
775
ilg
.Call(needsPrefix ? XmlFormatGeneratorStatics.WriteStartElementMethod3 : XmlFormatGeneratorStatics.WriteStartElementMethod2);
780
ilg
.Call(xmlWriterArg, XmlFormatGeneratorStatics.WriteEndElementMethod);