Beispiel #1
0
        public static T ExecuteRPC <T>(
            this IXboxConsole console,
            XDRPCExecutionOptions options,
            out ulong postMethodCallReturn,
            params XDRPCArgumentInfo[] args)
            where T : struct
        {
            Type t = typeof(T);

            postMethodCallReturn = 0UL;
            if (!XDRPCMarshaler.IsValidReturnType(t))
            {
                if (!t.IsValueType)
                {
                    throw new XDRPCInvalidReturnTypeException(t);
                }
                XDRPCStructArgumentInfo <T> structArgumentInfo     = new XDRPCStructArgumentInfo <T>(default(T), ArgumentType.Out);
                XDRPCArgumentInfo[]         xdrpcArgumentInfoArray = new XDRPCArgumentInfo[args.Length + 1];
                xdrpcArgumentInfoArray[0] = (XDRPCArgumentInfo)structArgumentInfo;
                Array.Copy((Array)args, 0, (Array)xdrpcArgumentInfoArray, 1, args.Length);
                int num = (int)XDRPCMarshaler.ExecuteRPC <uint>(console, options, xdrpcArgumentInfoArray);
                return(structArgumentInfo.Value);
            }
            XDRPCExecutionState.XDRPCCallFlags flags = XDRPCExecutionState.XDRPCCallFlags.IntegerReturn;
            if (t == typeof(float) || t == typeof(double))
            {
                flags = XDRPCExecutionState.XDRPCCallFlags.FloatingPointReturn;
            }
            XDRPCExecutionState xdrpcExecutionState = new XDRPCExecutionState(console, options, args, flags);

            xdrpcExecutionState.NoDevkit = XDRPCMarshaler.NoDevkit;
            xdrpcExecutionState.Invoke();
            if (options.PostMethodCall != XDRPCPostMethodCall.None)
            {
                postMethodCallReturn = xdrpcExecutionState.PostMethodCallReturnValue;
            }
            object obj = XDRPCMarshaler.UnpackReturnType(t, xdrpcExecutionState.ReturnValue);

            if (obj == null)
            {
                return(default(T));
            }
            return((T)obj);
        }