4 writes to ilg
System.Runtime.Serialization (4)
System\Runtime\Serialization\XmlFormatReaderGenerator.cs (4)
122
ilg
= new CodeGenerator();
185
ilg
= GenerateCollectionReaderHelper(collectionContract, false /*isGetOnlyCollection*/);
194
ilg
= GenerateCollectionReaderHelper(collectionContract, true /*isGetOnlyCollection*/);
201
ilg
= new CodeGenerator();
263 references to ilg
System.Runtime.Serialization (263)
System\Runtime\Serialization\XmlFormatReaderGenerator.cs (263)
126
ilg
.BeginMethod("Read" + classContract.StableName.Name + "FromXml", Globals.TypeOfXmlFormatClassReaderDelegate, memberAccessFlag);
144
ilg
.Call(contextArg, XmlFormatGeneratorStatics.AddNewObjectMethod, objectLocal);
149
objectId =
ilg
.DeclareLocal(Globals.TypeOfString, "objectIdRead");
150
ilg
.Call(contextArg, XmlFormatGeneratorStatics.GetObjectIdMethod);
151
ilg
.Stloc(objectId);
159
ilg
.Call(objectLocal, XmlFormatGeneratorStatics.OnDeserializationMethod, null);
163
ilg
.Load(objectLocal);
171
ilg
.ConvertValue(objectLocal.LocalType, Globals.TypeOfDateTimeOffsetAdapter);
172
ilg
.Call(XmlFormatGeneratorStatics.GetDateTimeOffsetMethod);
173
ilg
.ConvertValue(Globals.TypeOfDateTimeOffset,
ilg
.CurrentMethod.ReturnType);
177
ilg
.ConvertValue(objectLocal.LocalType,
ilg
.CurrentMethod.ReturnType);
180
return (XmlFormatClassReaderDelegate)
ilg
.EndMethod();
187
ilg
.Load(objectLocal);
188
ilg
.ConvertValue(objectLocal.LocalType,
ilg
.CurrentMethod.ReturnType);
189
return (XmlFormatCollectionReaderDelegate)
ilg
.EndMethod();
196
return (XmlFormatGetOnlyCollectionReaderDelegate)
ilg
.EndMethod();
207
ilg
.BeginMethod("Read" + collectionContract.StableName.Name + "FromXml" + "IsGetOnly", Globals.TypeOfXmlFormatGetOnlyCollectionReaderDelegate, memberAccessFlag);
211
ilg
.BeginMethod("Read" + collectionContract.StableName.Name + "FromXml" + string.Empty, Globals.TypeOfXmlFormatCollectionReaderDelegate, memberAccessFlag);
227
collectionContractArg =
ilg
.GetArg(4);
228
return
ilg
;
233
xmlReaderArg =
ilg
.GetArg(0);
234
contextArg =
ilg
.GetArg(1);
235
memberNamesArg =
ilg
.GetArg(2);
236
memberNamespacesArg =
ilg
.GetArg(3);
243
ilg
.Call(contextArg, XmlFormatGeneratorStatics.DemandMemberAccessPermissionMethod);
251
ilg
.Call(contextArg, XmlFormatGeneratorStatics.DemandSerializationFormatterPermissionMethod);
261
objectLocal =
ilg
.DeclareLocal(type, "objectDeserialized");
265
ilg
.LoadMember(Globals.TypeOfDBNull.GetField("Value"));
266
ilg
.Stloc(objectLocal);
272
ilg
.Ldloca(objectLocal);
273
ilg
.InitObj(type);
277
ilg
.New(classContract.GetNonAttributedTypeConstructor());
278
ilg
.Stloc(objectLocal);
283
ilg
.Call(null, XmlFormatGeneratorStatics.GetUninitializedObjectMethod, DataContract.GetIdForInitialization(classContract));
284
ilg
.ConvertValue(Globals.TypeOfObject, type);
285
ilg
.Stloc(objectLocal);
295
ilg
.LoadAddress(objectLocal);
296
ilg
.ConvertAddress(objectLocal.LocalType, objectType);
297
ilg
.Load(contextArg);
298
ilg
.LoadMember(XmlFormatGeneratorStatics.GetStreamingContextMethod);
299
ilg
.Call(classContract.OnDeserializing);
309
ilg
.LoadAddress(objectLocal);
310
ilg
.ConvertAddress(objectLocal.LocalType, objectType);
311
ilg
.Load(contextArg);
312
ilg
.LoadMember(XmlFormatGeneratorStatics.GetStreamingContextMethod);
313
ilg
.Call(classContract.OnDeserialized);
326
ilg
.Load(contextArg);
327
ilg
.LoadAddress(objectLocal);
328
ilg
.ConvertAddress(objectLocal.LocalType, Globals.TypeOfIObjectReference);
329
ilg
.Load(objectId);
330
ilg
.Call(XmlFormatGeneratorStatics.GetRealObjectMethod);
331
ilg
.ConvertValue(Globals.TypeOfObject,
ilg
.CurrentMethod.ReturnType);
341
LocalBuilder extensionDataLocal =
ilg
.DeclareLocal(Globals.TypeOfExtensionDataObject, "extensionData");
342
ilg
.New(XmlFormatGeneratorStatics.ExtensionDataObjectCtor);
343
ilg
.Store(extensionDataLocal);
351
ilg
.Call(objectLocal, extensionDataSetMethod, extensionDataLocal);
362
ilg
.Call(contextArg, XmlFormatGeneratorStatics.IncrementItemCountMethod, memberCount);
364
LocalBuilder memberIndexLocal =
ilg
.DeclareLocal(Globals.TypeOfInt, "memberIndex", -1);
369
LocalBuilder requiredIndexLocal = hasRequiredMembers ?
ilg
.DeclareLocal(Globals.TypeOfInt, "requiredIndex", firstRequiredMember) : null;
371
object forReadElements =
ilg
.For(null, null, null);
372
ilg
.Call(null, XmlFormatGeneratorStatics.MoveToNextElementMethod, xmlReaderArg);
373
ilg
.IfFalseBreak(forReadElements);
375
ilg
.Call(contextArg, XmlFormatGeneratorStatics.GetMemberIndexWithRequiredMembersMethod, xmlReaderArg, memberNamesArg, memberNamespacesArg, memberIndexLocal, requiredIndexLocal, extensionDataLocal);
377
ilg
.Call(contextArg, XmlFormatGeneratorStatics.GetMemberIndexMethod, xmlReaderArg, memberNamesArg, memberNamespacesArg, memberIndexLocal, extensionDataLocal);
380
Label[] memberLabels =
ilg
.Switch(memberCount);
382
ilg
.EndSwitch();
386
ilg
.Pop();
388
ilg
.EndFor();
391
ilg
.If(requiredIndexLocal, Cmp.LessThan, memberCount);
392
ilg
.Call(null, XmlFormatGeneratorStatics.ThrowRequiredMemberMissingExceptionMethod, xmlReaderArg, memberIndexLocal, requiredIndexLocal, memberNamesArg);
393
ilg
.EndIf();
406
ilg
.Case(memberLabels[memberCount], dataMember.Name);
413
ilg
.Set(requiredIndexLocal, nextRequiredIndex);
420
ilg
.LoadAddress(objectLocal);
421
ilg
.LoadMember(dataMember.MemberInfo);
422
value =
ilg
.DeclareLocal(memberType, dataMember.Name + "Value");
423
ilg
.Stloc(value);
424
ilg
.Call(contextArg, XmlFormatGeneratorStatics.StoreCollectionMemberInfoMethod, value);
430
ilg
.LoadAddress(objectLocal);
431
ilg
.ConvertAddress(objectLocal.LocalType, objectType);
432
ilg
.Ldloc(value);
433
ilg
.StoreMember(dataMember.MemberInfo);
435
ilg
.Set(memberIndexLocal, memberCount);
436
ilg
.EndCase();
466
ilg
.LoadAddress(objectLocal);
467
ilg
.ConvertAddress(objectLocal.LocalType, objectType);
468
ilg
.Call(contextArg, XmlFormatGeneratorStatics.ReadSerializationInfoMethod, xmlReaderArg, classContract.UnderlyingType);
469
ilg
.Load(contextArg);
470
ilg
.LoadMember(XmlFormatGeneratorStatics.GetStreamingContextMethod);
471
ilg
.Call(ctor);
476
LocalBuilder value =
ilg
.DeclareLocal(type, "valueRead");
488
LocalBuilder objectId =
ilg
.DeclareLocal(Globals.TypeOfString, "objectIdRead");
489
ilg
.Call(contextArg, XmlFormatGeneratorStatics.ReadAttributesMethod, xmlReaderArg);
490
ilg
.Call(contextArg, XmlFormatGeneratorStatics.ReadIfNullOrRefMethod, xmlReaderArg, type, DataContract.IsTypeSerializable(type));
491
ilg
.Stloc(objectId);
493
ilg
.If(objectId, Cmp.EqualTo, Globals.NullObjectId);
496
ilg
.LoadAddress(value);
497
ilg
.InitObj(value.LocalType);
503
ilg
.Load(null);
504
ilg
.Stloc(value);
510
ilg
.ElseIfIsEmptyString(objectId);
511
ilg
.Call(contextArg, XmlFormatGeneratorStatics.GetObjectIdMethod);
512
ilg
.Stloc(objectId);
515
ilg
.IfNotIsEmptyString(objectId);
517
ilg
.EndIf();
522
value =
ilg
.DeclareLocal(type, "innerValueRead");
527
ilg
.Call(xmlReaderArg, primitiveContract.XmlFormatReaderMethod);
528
ilg
.Stloc(value);
530
ilg
.Call(contextArg, XmlFormatGeneratorStatics.AddNewObjectMethod, value);
537
ilg
.Else();
542
ilg
.Call(contextArg, XmlFormatGeneratorStatics.GetExistingObjectMethod, objectId, type, name, ns);
543
ilg
.ConvertValue(Globals.TypeOfObject, type);
544
ilg
.Stloc(value);
546
ilg
.EndIf();
550
ilg
.If(objectId, Cmp.NotEqualTo, Globals.NullObjectId);
552
ilg
.EndIf();
566
ilg
.Load(contextArg);
567
ilg
.Load(xmlReaderArg);
569
ilg
.Load(DataContract.GetId(declaredType.TypeHandle));
570
ilg
.Ldtoken(declaredType);
571
ilg
.Load(name);
572
ilg
.Load(ns);
573
ilg
.Call(XmlFormatGeneratorStatics.InternalDeserializeMethod);
576
ilg
.Call(XmlFormatGeneratorStatics.UnboxPointer);
578
ilg
.ConvertValue(Globals.TypeOfObject, type);
579
ilg
.Stloc(value);
585
ilg
.LoadAddress(outerValue);
586
ilg
.Load(innerValue);
590
ilg
.New(type.GetConstructor(new Type[] { innerType }));
593
ilg
.Call(outerType.GetConstructor(new Type[] { innerType }));
630
objectLocal =
ilg
.DeclareLocal(type, "objectDeserialized");
635
ilg
.Ldloca(objectLocal);
636
ilg
.InitObj(type);
640
ilg
.New(constructor);
641
ilg
.Stloc(objectLocal);
642
ilg
.Call(contextArg, XmlFormatGeneratorStatics.AddNewObjectMethod, objectLocal);
646
LocalBuilder size =
ilg
.DeclareLocal(Globals.TypeOfInt, "arraySize");
647
ilg
.Call(contextArg, XmlFormatGeneratorStatics.GetArraySizeMethod);
648
ilg
.Stloc(size);
650
LocalBuilder objectId =
ilg
.DeclareLocal(Globals.TypeOfString, "objectIdRead");
651
ilg
.Call(contextArg, XmlFormatGeneratorStatics.GetObjectIdMethod);
652
ilg
.Stloc(objectId);
658
ilg
.IfNot();
661
ilg
.If(size, Cmp.EqualTo, -1);
666
growingCollection =
ilg
.DeclareLocal(type, "growingCollection");
667
ilg
.NewArray(itemType, 32);
668
ilg
.Stloc(growingCollection);
670
LocalBuilder i =
ilg
.DeclareLocal(Globals.TypeOfInt, "i");
671
object forLoop =
ilg
.For(i, 0, Int32.MaxValue);
673
ilg
.If();
674
ilg
.Call(contextArg, XmlFormatGeneratorStatics.IncrementItemCountMethod, 1);
679
ilg
.Call(null, ensureArraySizeMethod, growingCollection, i);
680
ilg
.Stloc(growingCollection);
681
ilg
.StoreArrayElement(growingCollection, i, value);
685
ilg
.Else();
687
ilg
.If();
688
ilg
.Break(forLoop);
689
ilg
.Else();
691
ilg
.EndIf();
692
ilg
.EndIf();
694
ilg
.EndFor();
698
ilg
.Call(null, trimArraySizeMethod, growingCollection, i);
699
ilg
.Stloc(objectLocal);
700
ilg
.Call(contextArg, XmlFormatGeneratorStatics.AddNewObjectWithIdMethod, objectId, objectLocal);
702
ilg
.Else();
704
ilg
.Call(contextArg, XmlFormatGeneratorStatics.IncrementItemCountMethod, size);
707
ilg
.NewArray(itemType, size);
708
ilg
.Stloc(objectLocal);
709
ilg
.Call(contextArg, XmlFormatGeneratorStatics.AddNewObjectMethod, objectLocal);
711
LocalBuilder j =
ilg
.DeclareLocal(Globals.TypeOfInt, "j");
712
ilg
.For(j, 0, size);
714
ilg
.If();
717
ilg
.StoreArrayElement(objectLocal, j, itemValue);
720
ilg
.Else();
722
ilg
.EndIf();
723
ilg
.EndFor();
724
ilg
.Call(contextArg, XmlFormatGeneratorStatics.CheckEndOfArrayMethod, xmlReaderArg, size, memberNamesArg, memberNamespacesArg);
725
ilg
.EndIf();
729
ilg
.Else();
730
ilg
.Call(contextArg, XmlFormatGeneratorStatics.AddNewObjectWithIdMethod, objectId, objectLocal);
731
ilg
.EndIf();
743
objectLocal =
ilg
.DeclareLocal(type, "objectDeserialized");
744
ilg
.Load(contextArg);
745
ilg
.LoadMember(XmlFormatGeneratorStatics.GetCollectionMemberMethod);
746
ilg
.ConvertValue(Globals.TypeOfObject, type);
747
ilg
.Stloc(objectLocal);
751
ilg
.If();
752
ilg
.If(objectLocal, Cmp.EqualTo, null);
753
ilg
.Call(null, XmlFormatGeneratorStatics.ThrowNullValueReturnedForGetOnlyCollectionExceptionMethod, type);
755
ilg
.Else();
756
LocalBuilder size =
ilg
.DeclareLocal(Globals.TypeOfInt, "arraySize");
759
ilg
.Load(objectLocal);
760
ilg
.Call(XmlFormatGeneratorStatics.GetArrayLengthMethod);
761
ilg
.Stloc(size);
764
ilg
.Call(contextArg, XmlFormatGeneratorStatics.AddNewObjectMethod, objectLocal);
766
LocalBuilder i =
ilg
.DeclareLocal(Globals.TypeOfInt, "i");
767
object forLoop =
ilg
.For(i, 0, Int32.MaxValue);
769
ilg
.If();
770
ilg
.Call(contextArg, XmlFormatGeneratorStatics.IncrementItemCountMethod, 1);
774
ilg
.If(size, Cmp.EqualTo, i);
775
ilg
.Call(null, XmlFormatGeneratorStatics.ThrowArrayExceededSizeExceptionMethod, size, type);
776
ilg
.Else();
777
ilg
.StoreArrayElement(objectLocal, i, value);
778
ilg
.EndIf();
782
ilg
.Else();
784
ilg
.If();
785
ilg
.Break(forLoop);
786
ilg
.Else();
788
ilg
.EndIf();
789
ilg
.EndIf();
790
ilg
.EndFor();
791
ilg
.Call(contextArg, XmlFormatGeneratorStatics.CheckEndOfArrayMethod, xmlReaderArg, size, memberNamesArg, memberNamespacesArg);
793
ilg
.EndIf();
794
ilg
.EndIf();
832
ilg
.Load(xmlReaderArg);
833
ilg
.Load(contextArg);
834
ilg
.Load(memberNamesArg);
835
ilg
.Load(memberNamespacesArg);
836
ilg
.Load(size);
837
ilg
.Ldloca(objectLocal);
838
ilg
.Call(typeof(XmlReaderDelegator).GetMethod(readArrayMethod, Globals.ScanAllMembers));
848
ilg
.Call(contextArg, XmlFormatGeneratorStatics.ResetAttributesMethod);
849
LocalBuilder value =
ilg
.DeclareLocal(itemType, "valueRead");
850
ilg
.Load(collectionContractArg);
851
ilg
.Call(XmlFormatGeneratorStatics.GetItemContractMethod);
852
ilg
.Load(xmlReaderArg);
853
ilg
.Load(contextArg);
854
ilg
.Call(XmlFormatGeneratorStatics.ReadXmlValueMethod);
855
ilg
.ConvertValue(Globals.TypeOfObject, itemType);
856
ilg
.Stloc(value);
876
LocalBuilder pairKey =
ilg
.DeclareLocal(keyMember.MemberType, keyMember.Name);
877
LocalBuilder pairValue =
ilg
.DeclareLocal(valueMember.MemberType, valueMember.Name);
878
ilg
.LoadAddress(value);
879
ilg
.LoadMember(keyMember.MemberInfo);
880
ilg
.Stloc(pairKey);
881
ilg
.LoadAddress(value);
882
ilg
.LoadMember(valueMember.MemberInfo);
883
ilg
.Stloc(pairValue);
885
ilg
.Call(collection, collectionContract.AddMethod, pairKey, pairValue);
887
ilg
.Pop();
891
ilg
.Call(collection, collectionContract.AddMethod, value);
893
ilg
.Pop();
900
ilg
.If();
901
ilg
.Call(contextArg, XmlFormatGeneratorStatics.SkipUnknownElementMethod, xmlReaderArg);
902
ilg
.Dec(iterator);
903
ilg
.Else();
905
ilg
.EndIf();
910
ilg
.Call(xmlReaderArg, XmlFormatGeneratorStatics.IsStartElementMethod2, nameArg, nsArg);
915
ilg
.Call(xmlReaderArg, XmlFormatGeneratorStatics.IsStartElementMethod0);
920
ilg
.Load(xmlReaderArg);
921
ilg
.LoadMember(XmlFormatGeneratorStatics.NodeTypeProperty);
922
ilg
.Load(XmlNodeType.EndElement);
923
ilg
.Ceq();
928
ilg
.Call(null, XmlFormatGeneratorStatics.CreateUnexpectedStateExceptionMethod, expectedState, xmlReaderArg);
929
ilg
.Throw();
935
ilg
.CallStringFormat(msg, values);
937
ilg
.Load(msg);
943
ilg
.New(XmlFormatGeneratorStatics.SerializationExceptionCtor);
944
ilg
.Throw();