private static void GenerateReadDelegate(ReaderGenerationContext context, Type type, Action pushObjectIdOntoStackAction)
{
var invocationListLengthLocal = context.Generator.DeclareLocal(typeof(int));
var targetLocal = context.Generator.DeclareLocal(typeof(object));
GenerateReadPrimitive(context, typeof(int));
context.Generator.StoreLocalValueFromStack(invocationListLengthLocal);
GeneratorHelper.GenerateLoop(context, invocationListLengthLocal, cl =>
{
GenerateReadField(context, typeof(object));
context.Generator.StoreLocalValueFromStack(targetLocal);
GenerateReadMethod(context);
context.Generator.PushTypeOntoStack(type);
context.Generator.PushLocalValueOntoStack(targetLocal);
context.PushDeserializedObjectsCollectionOntoStack();
pushObjectIdOntoStackAction();
context.Generator.GenerateCodeCall <MethodInfo, Type, object, AutoResizingList <object>, int>((method, t, target, deserializedObjects, objectId) =>
{
var del = Delegate.CreateDelegate(t, target, method);
deserializedObjects[objectId] = Delegate.Combine((Delegate)deserializedObjects[objectId], del);
});
});
}