Пример #1
0
        public unsafe ExecutionResult *CreateExecutionResult(bool failed, type_primitive_id type, object value)
        {
            ExecutionResult *er = CreateExecutionResult(failed, type);

            er->ptr = MetacallDef.GetIntPtr(type, value);

            return(er);
        }
Пример #2
0
        public unsafe ExecutionResult *Execute(string function, Parameters[] parameters)
        {
            var objs = new object[parameters.Length];

            var con = this.functions[function];

            for (int i = 0; i < con.Parameters.Length; i++)
            {
                objs[i] = MetacallDef.GetValue(parameters[i].type, parameters[i].ptr);
            }

            var result = con.Method.Invoke(null, objs.Take(con.Parameters.Length).ToArray());

            if (result == null)
            {
                return(CreateExecutionResult(false, MetacallDef.Get(con.RetunType)));
            }
            else
            {
                return(CreateExecutionResult(false, MetacallDef.Get(con.RetunType), result));
            }
        }
Пример #3
0
        public unsafe ExecutionResult *Execute(string function)
        {
            var con = this.functions[function];

            try
            {
                var result = con.Method.Invoke(null, null);

                if (result == null)
                {
                    return(CreateExecutionResult(false, MetacallDef.Get(con.RetunType)));
                }
                else
                {
                    return(CreateExecutionResult(false, MetacallDef.Get(con.RetunType), result));
                }
            }
            catch (Exception ex)
            {
                this.log.Error("Error executing function " + function, ex);
            }

            return(null);
        }