Example #1
0
 private static void EmitInvokeCallback(CompilerContext ctx, MethodInfo method, bool copyValue, Type constructType, Type type)
 {
     if (method != null)
     {
         if (copyValue)
         {
             ctx.CopyValue();
         }
         ParameterInfo[] parameters = method.GetParameters();
         bool            flag       = true;
         for (int i = 0; i < parameters.Length; i++)
         {
             Type parameterType = parameters[0].ParameterType;
             if (parameterType == ctx.MapType(typeof(SerializationContext)))
             {
                 ctx.LoadSerializationContext();
             }
             else if (parameterType == ctx.MapType(typeof(Type)))
             {
                 Type type3 = constructType;
                 if (type3 == null)
                 {
                     type3 = type;
                 }
                 ctx.LoadValue(type3);
             }
             else if (parameterType == ctx.MapType(typeof(StreamingContext)))
             {
                 ctx.LoadSerializationContext();
                 MethodInfo info = ctx.MapType(typeof(SerializationContext)).GetMethod("op_Implicit", new Type[] { ctx.MapType(typeof(SerializationContext)) });
                 if (info != null)
                 {
                     ctx.EmitCall(info);
                     flag = true;
                 }
             }
             else
             {
                 flag = false;
             }
         }
         if (!flag)
         {
             throw CallbackSet.CreateInvalidCallbackSignature(method);
         }
         ctx.EmitCall(method);
         if ((constructType != null) && (method.ReturnType == ctx.MapType(typeof(object))))
         {
             ctx.CastFromObject(type);
         }
     }
 }
Example #2
0
        private object InvokeCallback(MethodInfo method, object obj, SerializationContext context)
        {
            object obj2 = null;

            object[] objArray;
            bool     flag;

            if (method == null)
            {
                return(obj2);
            }
            ParameterInfo[] parameters = method.GetParameters();
            if (parameters.Length == 0)
            {
                objArray = null;
                flag     = true;
            }
            else
            {
                objArray = new object[parameters.Length];
                flag     = true;
                for (int i = 0; i < objArray.Length; i++)
                {
                    object constructType;
                    Type   parameterType = parameters[i].ParameterType;
                    if (parameterType == typeof(SerializationContext))
                    {
                        constructType = context;
                    }
                    else if (parameterType == typeof(Type))
                    {
                        constructType = this.constructType;
                    }
                    else if (parameterType == typeof(StreamingContext))
                    {
                        constructType = (StreamingContext)context;
                    }
                    else
                    {
                        constructType = null;
                        flag          = false;
                    }
                    objArray[i] = constructType;
                }
            }
            if (!flag)
            {
                throw CallbackSet.CreateInvalidCallbackSignature(method);
            }
            return(method.Invoke(obj, objArray));
        }
Example #3
0
        private object InvokeCallback(MethodInfo method, object obj, SerializationContext context)
        {
            object result = null;

            if (method != (MethodInfo)null)
            {
                ParameterInfo[] parameters = method.GetParameters();
                object[]        array;
                bool            flag;
                if (parameters.Length == 0)
                {
                    array = null;
                    flag  = true;
                }
                else
                {
                    array = new object[parameters.Length];
                    flag  = true;
                    for (int i = 0; i < array.Length; i++)
                    {
                        Type   parameterType = parameters[i].ParameterType;
                        object obj2;
                        if (parameterType == typeof(SerializationContext))
                        {
                            obj2 = context;
                        }
                        else if (parameterType == typeof(Type))
                        {
                            obj2 = constructType;
                        }
                        else
                        {
                            obj2 = null;
                            flag = false;
                        }
                        array[i] = obj2;
                    }
                }
                if (flag)
                {
                    result = method.Invoke(obj, array);
                    goto IL_00a1;
                }
                throw CallbackSet.CreateInvalidCallbackSignature(method);
            }
            goto IL_00a1;
IL_00a1:
            return(result);
        }