private static void EmitProcessAndEncodeAsyncWithRetval(HandlerClassBuildingContext classContext, IEmittingContext emittingContext, Type pureRetvalType) { var encodeDeferredMethod = CreateEncodeDeferredMethod(classContext, pureRetvalType); var continueWithMethod = TaskMethods.ContinueWith(pureRetvalType, typeof(byte[])); var il = emittingContext.IL; il.Ldarg(0); il.Ldftn(encodeDeferredMethod); il.Newobj(FuncMethods.Constructor(typeof(Task <>).MakeGenericType(pureRetvalType), typeof(byte[]))); il.Callvirt(continueWithMethod); }
private void EmitProcessAsyncWithRetval(ProxyClassBuildingContext classContext, IEmittingContext emittingContext, string parameterMethodName, IReadOnlyList <Type> genericTypeArguments, Type retvalType) { var pureRetvalType = retvalType.GetGenericArguments().Single(); var decodeDeferredMethod = CreateDecodeDeferredMethod(classContext, parameterMethodName, genericTypeArguments, pureRetvalType); if (decodeDeferredMethod.IsGenericMethodDefinition) { decodeDeferredMethod = decodeDeferredMethod.MakeGenericMethod(genericTypeArguments.ToArray()); } var funcConstructor = FuncMethods.Constructor(typeof(Task <byte[]>), pureRetvalType); var continueWithMethod = TaskMethods.ContinueWith(typeof(byte[]), pureRetvalType); var il = emittingContext.IL; il.Callvirt(OutgoingRequestProcessorMethods.ProcessAsync); il.Ldarg(0); il.Ldftn(decodeDeferredMethod); il.Newobj(funcConstructor); il.Callvirt(continueWithMethod); }