2 writes to ilg
System.Runtime.Serialization (2)
System\Runtime\Serialization\Json\JsonFormatWriterGenerator.cs (2)
91
ilg
= new CodeGenerator();
122
ilg
= new CodeGenerator();
177 references to ilg
System.Runtime.Serialization (177)
System\Runtime\Serialization\Json\JsonFormatWriterGenerator.cs (177)
95
BeginMethod(
ilg
, "Write" + classContract.StableName.Name + "ToJson", typeof(JsonFormatClassWriterDelegate), memberAccessFlag);
109
memberNamesArg =
ilg
.GetArg(4);
117
return (JsonFormatClassWriterDelegate)
ilg
.EndMethod();
126
BeginMethod(
ilg
, "Write" + collectionContract.StableName.Name + "ToJson", typeof(JsonFormatCollectionWriterDelegate), memberAccessFlag);
146
return (JsonFormatCollectionWriterDelegate)
ilg
.EndMethod();
167
xmlWriterArg =
ilg
.GetArg(0);
168
contextArg =
ilg
.GetArg(2);
169
dataContractArg =
ilg
.GetArg(3);
171
objectLocal =
ilg
.DeclareLocal(objType, "objSerialized");
172
ArgBuilder objectArg =
ilg
.GetArg(1);
173
ilg
.Load(objectArg);
181
ilg
.ConvertValue(objectArg.ArgType, Globals.TypeOfDateTimeOffset);
182
ilg
.Call(XmlFormatGeneratorStatics.GetDateTimeOffsetAdapterMethod);
186
ilg
.ConvertValue(objectArg.ArgType, objType);
188
ilg
.Stloc(objectLocal);
196
ilg
.Call(contextArg, XmlFormatGeneratorStatics.DemandMemberAccessPermissionMethod);
204
ilg
.Call(contextArg, XmlFormatGeneratorStatics.DemandSerializationFormatterPermissionMethod);
220
ilg
.Load(contextArg);
221
ilg
.LoadMember(XmlFormatGeneratorStatics.SerializeReadOnlyTypesProperty);
222
ilg
.IfNot();
223
ilg
.Load(dataContractArg);
224
ilg
.LoadMember(serializationExceptionMessageProperty);
225
ilg
.Load(null);
226
ilg
.Call(XmlFormatGeneratorStatics.ThrowInvalidDataContractExceptionMethod);
227
ilg
.EndIf();
236
ilg
.LoadAddress(objectLocal);
237
ilg
.Load(contextArg);
238
ilg
.Call(XmlFormatGeneratorStatics.GetStreamingContextMethod);
239
ilg
.Call(classContract.OnSerializing);
249
ilg
.LoadAddress(objectLocal);
250
ilg
.Load(contextArg);
251
ilg
.Call(XmlFormatGeneratorStatics.GetStreamingContextMethod);
252
ilg
.Call(classContract.OnSerialized);
262
ilg
.Call(contextArg, JsonFormatGeneratorStatics.WriteJsonISerializableMethod, xmlWriterArg, objectLocal);
268
LocalBuilder extensionDataLocal =
ilg
.DeclareLocal(Globals.TypeOfExtensionDataObject, "extensionData");
269
ilg
.Load(objectLocal);
270
ilg
.ConvertValue(objectLocal.LocalType, Globals.TypeOfIExtensibleDataObject);
271
ilg
.LoadMember(JsonFormatGeneratorStatics.ExtensionDataProperty);
272
ilg
.Store(extensionDataLocal);
273
ilg
.Call(contextArg, XmlFormatGeneratorStatics.WriteExtensionDataMethod, xmlWriterArg, extensionDataLocal, -1);
287
ilg
.Call(contextArg, XmlFormatGeneratorStatics.IncrementItemCountMethod, classContract.Members.Count);
296
ilg
.Load(contextArg);
297
ilg
.Call(XmlFormatGeneratorStatics.StoreIsGetOnlyCollectionMethod);
302
ilg
.IfNotDefaultValue(memberValue);
312
ilg
.Call(null, JsonFormatGeneratorStatics.WriteJsonNameWithMappingMethod, xmlWriterArg, memberNamesArg, i + childElementIndex);
324
ilg
.Call(contextArg, XmlFormatGeneratorStatics.WriteExtensionDataMethod, xmlWriterArg, extensionDataLocal, memberCount);
329
ilg
.Else();
330
ilg
.Call(null, XmlFormatGeneratorStatics.ThrowRequiredMemberMustBeEmittedMethod, member.Name, classContract.UnderlyingType);
332
ilg
.EndIf();
343
ilg
.LoadAddress(objectLocal);
344
ilg
.LoadMember(member.MemberInfo);
345
LocalBuilder memberValue =
ilg
.DeclareLocal(member.MemberType, member.Name + "Value");
346
ilg
.Stloc(memberValue);
352
LocalBuilder itemName =
ilg
.DeclareLocal(typeof(XmlDictionaryString), "itemName");
353
ilg
.Load(contextArg);
354
ilg
.LoadMember(JsonFormatGeneratorStatics.CollectionItemNameProperty);
355
ilg
.Store(itemName);
360
LocalBuilder i =
ilg
.DeclareLocal(Globals.TypeOfInt, "i");
362
ilg
.Call(contextArg, XmlFormatGeneratorStatics.IncrementArrayCountMethod, xmlWriterArg, objectLocal);
367
ilg
.For(i, 0, objectLocal);
371
ilg
.LoadArrayElement(objectLocal, i);
372
LocalBuilder memberValue =
ilg
.DeclareLocal(itemType, "memberValue");
373
ilg
.Stloc(memberValue);
377
ilg
.EndFor();
400
ilg
.Call(contextArg, incrementCollectionCountMethod, xmlWriterArg, objectLocal);
458
LocalBuilder currentValue =
ilg
.DeclareLocal(elementType, "currentValue");
460
LocalBuilder enumerator =
ilg
.DeclareLocal(enumeratorType, "enumerator");
461
ilg
.Call(objectLocal, collectionContract.GetEnumeratorMethod);
465
ilg
.ConvertValue(collectionContract.GetEnumeratorMethod.ReturnType, Globals.TypeOfIDictionaryEnumerator);
466
ilg
.New(dictEnumCtor);
472
ilg
.ConvertValue(collectionContract.GetEnumeratorMethod.ReturnType, ctorParam);
473
ilg
.New(dictEnumCtor);
475
ilg
.Stloc(enumerator);
484
ilg
.Load(contextArg);
485
ilg
.LoadMember(JsonFormatGeneratorStatics.UseSimpleDictionaryFormatWriteProperty);
486
ilg
.If();
488
LocalBuilder pairKey =
ilg
.DeclareLocal(Globals.TypeOfString, "key");
489
LocalBuilder pairValue =
ilg
.DeclareLocal(keyValueTypes[1], "value");
490
ilg
.ForEach(currentValue, elementType, enumeratorType, enumerator, getCurrentMethod);
492
ilg
.LoadAddress(currentValue);
493
ilg
.LoadMember(genericDictionaryKeyProperty);
494
ilg
.ToString(keyValueTypes[0]);
495
ilg
.Stloc(pairKey);
497
ilg
.LoadAddress(currentValue);
498
ilg
.LoadMember(genericDictionaryValueProperty);
499
ilg
.Stloc(pairValue);
505
ilg
.EndForEach(moveNextMethod);
506
ilg
.Else();
511
ilg
.ForEach(currentValue, elementType, enumeratorType, enumerator, getCurrentMethod);
514
ilg
.Call(contextArg, XmlFormatGeneratorStatics.IncrementItemCountMethod, 1);
522
ilg
.Call(dataContractArg, JsonFormatGeneratorStatics.GetItemContractMethod);
523
ilg
.Call(JsonFormatGeneratorStatics.GetRevisedItemContractMethod);
524
ilg
.Call(JsonFormatGeneratorStatics.GetJsonDataContractMethod);
525
ilg
.Load(xmlWriterArg);
526
ilg
.Load(currentValue);
527
ilg
.ConvertValue(currentValue.LocalType, Globals.TypeOfObject);
528
ilg
.Load(contextArg);
529
ilg
.Load(currentValue.LocalType);
530
ilg
.LoadMember(JsonFormatGeneratorStatics.TypeHandleProperty);
531
ilg
.Call(JsonFormatGeneratorStatics.WriteJsonValueMethod);
539
ilg
.EndForEach(moveNextMethod);
543
ilg
.EndIf();
557
ilg
.Load(xmlWriterArg);
561
ilg
.Load(contextArg);
562
ilg
.Load(xmlWriterArg);
567
ilg
.Load(value);
571
ilg
.LoadAddress(objectLocal);
572
ilg
.LoadMember(memberInfo);
576
ilg
.LoadArrayElement(objectLocal, arrayItemIndex);
581
ilg
.Load(name);
585
ilg
.LoadArrayElement(memberNamesArg, nameIndex);
588
ilg
.Load(null);
590
ilg
.Call(primitiveContract.XmlFormatWriterMethod);
630
ilg
.Call(xmlWriterArg, typeof(JsonWriterDelegator).GetMethod(writeArrayMethod, Globals.ScanAllMembers, null, new Type[] { type, typeof(XmlDictionaryString), typeof(XmlDictionaryString) }, null), value, itemName, null);
638
ilg
.Call(xmlWriterArg, JsonFormatGeneratorStatics.WriteAttributeStringMethod,
647
ilg
.Call(xmlWriterArg, JsonFormatGeneratorStatics.WriteAttributeStringMethod,
659
ilg
.Load(memberValue);
660
ilg
.Load(memberType);
661
ilg
.Call(JsonFormatGeneratorStatics.BoxPointer);
663
memberValue =
ilg
.DeclareLocal(memberType, "memberValueRefPointer");
664
ilg
.Store(memberValue);
672
ilg
.Call(xmlWriterArg, primitiveContract.XmlFormatContentWriterMethod, memberValue);
685
ilg
.Load(memberValue);
686
ilg
.Load(null);
687
ilg
.Ceq();
689
ilg
.If();
690
ilg
.Call(contextArg, XmlFormatGeneratorStatics.WriteNullMethod, xmlWriterArg, memberType, DataContract.IsTypeSerializable(memberType));
691
ilg
.Else();
697
ilg
.Call(xmlWriterArg, primitiveContract.XmlFormatContentWriterMethod, memberValue);
701
ilg
.Call(contextArg, primitiveContract.XmlFormatContentWriterMethod, xmlWriterArg, memberValue);
710
ilg
.Load(memberValue);
711
ilg
.ConvertValue(memberValue.LocalType, Globals.TypeOfObject);
712
memberValue =
ilg
.DeclareLocal(Globals.TypeOfObject, "unwrappedMemberValue");
714
ilg
.Stloc(memberValue);
715
ilg
.If(memberValue, Cmp.EqualTo, null);
716
ilg
.Call(contextArg, XmlFormatGeneratorStatics.WriteNullMethod, xmlWriterArg, memberType, DataContract.IsTypeSerializable(memberType));
717
ilg
.Else();
723
ilg
.EndIf();
725
ilg
.EndIf();
731
ilg
.Load(contextArg);
732
ilg
.Load(xmlWriterArg);
733
ilg
.Load(memberValue);
734
ilg
.ConvertValue(memberValue.LocalType, Globals.TypeOfObject);
735
LocalBuilder typeHandleValue =
ilg
.DeclareLocal(typeof(RuntimeTypeHandle), "typeHandleValue");
736
ilg
.Call(null, typeof(Type).GetMethod("GetTypeHandle"), memberValue);
737
ilg
.Stloc(typeHandleValue);
738
ilg
.LoadAddress(typeHandleValue);
739
ilg
.Ldtoken(memberType);
740
ilg
.Call(typeof(RuntimeTypeHandle).GetMethod("Equals", new Type[] { typeof(RuntimeTypeHandle) }));
741
ilg
.Load(writeXsiType);
742
ilg
.Load(DataContract.GetId(memberType.TypeHandle));
743
ilg
.Ldtoken(memberType);
744
ilg
.Call(methodInfo);
750
Label onNull =
ilg
.DefineLabel();
751
Label end =
ilg
.DefineLabel();
752
ilg
.Load(memberValue);
756
ilg
.Dup();
757
ilg
.Call(XmlFormatGeneratorStatics.GetHasValueMethod.MakeGenericMethod(innerType));
758
ilg
.Brfalse(onNull);
759
ilg
.Call(XmlFormatGeneratorStatics.GetNullableValueMethod.MakeGenericMethod(innerType));
762
memberValue =
ilg
.DeclareLocal(memberType, "nullableUnwrappedMemberValue");
763
ilg
.Stloc(memberValue);
764
ilg
.Load(false); //isNull
765
ilg
.Br(end);
766
ilg
.MarkLabel(onNull);
767
ilg
.Pop();
768
ilg
.Call(XmlFormatGeneratorStatics.GetDefaultValueMethod.MakeGenericMethod(memberType));
769
ilg
.Stloc(memberValue);
770
ilg
.Load(true); //isNull
771
ilg
.MarkLabel(end);
777
ilg
.Load(xmlWriterArg);
781
ilg
.LoadArrayElement(memberNamesArg, nameIndex);
783
ilg
.Load(nameLocal);
786
ilg
.Load(null);
790
ilg
.Call(JsonFormatGeneratorStatics.WriteStartElementStringMethod);
794
ilg
.Call(JsonFormatGeneratorStatics.WriteStartElementMethod);
800
ilg
.Call(xmlWriterArg, JsonFormatGeneratorStatics.WriteEndElementMethod);