Beispiel #1
0
        /// <summary>
        /// Calls the specified function and assigns the result to this variable
        /// </summary>
        /// <param name="function"></param>
        /// <param name="arguments"></param>
        /// <param name="escapeMethod"></param>
        /// <returns></returns>
        public dynamic CallAssign(
            PyFunction function,
            List <object> arguments  = null,
            EscapeFlags escapeMethod = EscapeFlags.Quotes | EscapeFlags.StripNullItems,
            PyVariable target        = null
            )
        {
            string argumentsText = "";

            if (arguments != null)
            {
                List <string> textArguments = PythonInterop.EscapeArguments(arguments, escapeMethod);
                argumentsText = string.Join(", ", textArguments);
            }

            if (target == null)
            {
                target = this;
            }

            PythonInterop.EvalToVar(target, "{0}({1})", new List <object> {
                function.ToString(), argumentsText
            }, EscapeFlags.None);

            return(this.Value);
        }
Beispiel #2
0
 public dynamic CallFunction(
     string function,
     List <object> arguments  = null,
     EscapeFlags escapeMethod = EscapeFlags.Quotes | EscapeFlags.StripNullItems
     )
 {
     return(CallFunction(PyFunction.ClassFunction(function), arguments, escapeMethod));
 }
Beispiel #3
0
 public dynamic CallAssign(
     string function,
     List <object> arguments  = null,
     EscapeFlags escapeMethod = EscapeFlags.Quotes | EscapeFlags.StripNullItems,
     PyVariable target        = null
     )
 {
     return(CallAssign(PyFunction.ClassFunction(function), arguments, escapeMethod, target));
 }
Beispiel #4
0
 public dynamic CallFunction(
     PyFunction function,
     string argumentsBody
     )
 {
     return(PythonInterop.EvalToResult(string.Format("{0}.{1}({2})",
                                                     this.PyName, function.Function, argumentsBody
                                                     )).Value);
 }
Beispiel #5
0
        public dynamic CallFunction(
            PyFunction function,
            string argumentsBody,
            PyVariable target = null
            )
        {
            if (target == null)
            {
                target = PyVariableManager.LastResult;
            }

            return((PythonInterop.EvalToVar(target, string.Format("{0}.{1}({2})",
                                                                  this.PyName, function.Function, argumentsBody
                                                                  ))).Value);
        }
Beispiel #6
0
        public dynamic CallFunction(
            PyFunction function,
            List <object> arguments  = null,
            EscapeFlags escapeMethod = EscapeFlags.Quotes | EscapeFlags.StripNullItems
            )
        {
            if (arguments == null)
            {
                arguments = new List <object>();
            }

            List <string> textArguments = PythonInterop.EscapeArguments(arguments, escapeMethod);

            return(CallFunction(function, string.Join(", ", textArguments)));
        }
Beispiel #7
0
        public PyVariable NewInstance(List <object> arguments = null)
        {
            PyVariable instance = PyVariableManager.Get.NewVariable();

            List <object> args = new List <object>()
            {
                "self.bridge"
            };

            if (arguments != null)
            {
                args.AddRange(arguments);
            }

            return(instance.CallAssign(PyFunction.ClassFunction(this.ClassName), args));
        }
Beispiel #8
0
 public dynamic CallFunction(PyFunction function, params object[] args)
 {
     return(CallFunction(function, args.ToList()));
 }