Example #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);
        }
Example #2
0
        public string CallFunction(
            PythonFunction 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)));
        }
Example #3
0
        public dynamic CallFunction(
            PyFunction function,
            List <object> arguments  = null,
            EscapeFlags escapeMethod = EscapeFlags.Quotes | EscapeFlags.StripNullItems,
            PyVariable target        = null
            )
        {
            if (arguments == null)
            {
                arguments = new List <object>();
            }

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

            return(CallFunction(function, string.Join(", ", textArguments), target: target));
        }
Example #4
0
        public string CallFunction(
            PythonFunction 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(PythonInterop.EvalToResult(string.Format("{0}.{1}({2})",
                                                            this.PyName, function.Function, string.Join(", ", textArguments)
                                                            )));
        }