Пример #1
0
        /// <summary>
        /// Creates a FREObject
        /// </summary>
        /// <param name="value"></param>
        /// <param name="className">Name of the Class</param>
        /// <param name="args">Arguments to pass to the Class</param>
        /// <returns></returns>
        public static FREObject Init(this FREObject value, string className, params object[] args)
        {
            uint resultPtr = 0;
            var  argsArr   = new ArrayList();

            if (args != null)
            {
                for (var i = 0; i < args.Length; i++)
                {
                    argsArr.Add(args.ElementAt(i));
                }
            }

            var rawValue = FreSharpHelper.Core.getFREObject(className, FreSharpHelper.ArgsToArgv(argsArr),
                                                            FreSharpHelper.GetArgsC(argsArr), ref resultPtr);
            var status = (FreResultSharp)resultPtr;

            if (status == FreResultSharp.Ok)
            {
                return(rawValue);
            }

            FreSharpHelper.ThrowFreException(status, "cannot create class " + className, rawValue);
            return(FREObject.Zero);
        }
Пример #2
0
        /// <summary>
        /// Calls a method on a FREObject
        /// </summary>
        /// <param name="inFre"></param>
        /// <param name="method">The method name</param>
        /// <param name="args">Arguments to pass to the method</param>
        /// <returns></returns>
        public static FREObject Call(this FREObject inFre, string method, params object[] args)
        {
            uint resultPtr = 0;
            var  argsArr   = new ArrayList();

            if (args != null)
            {
                for (var i = 0; i < args.Length; i++)
                {
                    argsArr.Add(args.ElementAt(i));
                }
            }

            var ret = FreSharpHelper.Core.callMethod(inFre, method, FreSharpHelper.ArgsToArgv(argsArr),
                                                     FreSharpHelper.GetArgsC(argsArr), ref resultPtr);

            var status = (FreResultSharp)resultPtr;

            if (status == FreResultSharp.Ok)
            {
                return(ret);
            }

            FreSharpHelper.ThrowFreException(status, "cannot call method " + method, ret);
            return(FREObject.Zero);
        }
Пример #3
0
        /// <summary>
        /// Calls a method on a FREObject.
        /// </summary>
        /// <param name="freObject"></param>
        /// <param name="method">The method name.</param>
        /// <param name="args">Arguments to pass to the method.</param>
        /// <returns></returns>
        public static FREObject Call(this FREObject freObject, string method, params object[] args)
        {
            uint resultPtr = 0;
            var  argsArr   = new ArrayList();

            if (args != null)
            {
                for (var i = 0; i < args.Length; i++)
                {
                    argsArr.Add(args.ElementAt(i));
                }
            }

            var ret = FreSharpHelper.Core.callMethod(freObject, method, FreSharpHelper.ArgsToArgv(argsArr),
                                                     FreSharpHelper.GetArgsC(argsArr), ref resultPtr);

            var status = (FreResultSharp)resultPtr;

            if (status == FreResultSharp.Ok)
            {
                return(ret);
            }
            Logger.Error($"cannot call method {method} of {freObject.toString()}", status, ret);
            return(FREObject.Zero);
        }
Пример #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="value"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public static FREObject Init(this FREObject value, string name)
        {
            uint resultPtr = 0;
            var  argsArr   = new ArrayList();
            var  rawValue  = FreSharpHelper.Core.getFREObject(name, FreSharpHelper.ArgsToArgv(argsArr),
                                                              FreSharpHelper.GetArgsC(argsArr), ref resultPtr);
            var status = (FreResultSharp)resultPtr;

            if (status == FreResultSharp.Ok)
            {
                return(rawValue);
            }
            FreSharpHelper.ThrowFreException(status, "cannot create class " + name, rawValue);
            return(FREObject.Zero);
        }
Пример #5
0
        /// <summary>
        /// Creates a FREObject.
        /// </summary>
        /// <param name="value"></param>
        /// <param name="name">Name of the Class.</param>
        /// <returns></returns>
        public static FREObject Init(this FREObject value, string name)
        {
            uint resultPtr = 0;
            var  argsArr   = new ArrayList();
            var  ret       = FreSharpHelper.Core.getFREObject(name, FreSharpHelper.ArgsToArgv(argsArr),
                                                              FreSharpHelper.GetArgsC(argsArr), ref resultPtr);
            var status = (FreResultSharp)resultPtr;

            if (status == FreResultSharp.Ok)
            {
                return(ret);
            }
            Logger.Error($"cannot create class {name}", status, ret);
            return(FREObject.Zero);
        }
Пример #6
0
        /// <summary>
        /// Adds one or more elements to the end of an array and returns the new length of the array.
        /// </summary>
        /// <param name="args">One or more values to append to the array.</param>
        public void Push(params object[] args)
        {
            uint resultPtr = 0;
            var  argsArr   = new ArrayList();

            if (args != null)
            {
                for (var i = 0; i < args.Length; i++)
                {
                    argsArr.Add(args.ElementAt(i));
                }
            }

            var ret = FreSharpHelper.Core.callMethod(RawValue, "push", FreSharpHelper.ArgsToArgv(argsArr),
                                                     FreSharpHelper.GetArgsC(argsArr), ref resultPtr);
            var status = (FreResultSharp)resultPtr;

            if (status == FreResultSharp.Ok)
            {
                return;
            }
            Logger.Error("cannot call method push on FREArray", status, ret);
        }
Пример #7
0
        /// <summary>
        /// Calls a method on a FREArray
        /// </summary>
        /// <param name="inFre"></param>
        /// <param name="methodName">The method name</param>
        /// <param name="args">Arguments to pass to the method</param>
        /// <returns></returns>
        public static FREArray Call(this FREObject inFre, string methodName, ArrayList args)
        {
            uint resultPtr = 0;
            var  ret       = new FREArray(FreSharpHelper.Core.callMethod(inFre, methodName,
                                                                         FreSharpHelper.ArgsToArgv(args), FreSharpHelper.GetArgsC(args), ref resultPtr));
            var status = (FreResultSharp)resultPtr;

            if (status == FreResultSharp.Ok)
            {
                return(ret);
            }

            FreSharpHelper.ThrowFreException(status, "cannot call method " + methodName, ret.RawValue);
            return(null);
        }
Пример #8
0
        /// <summary>
        /// Calls a method on a FREArray.
        /// </summary>
        /// <param name="freObject"></param>
        /// <param name="methodName">The method name.</param>
        /// <param name="args">Arguments to pass to the method.</param>
        /// <returns></returns>
        public static FREArray Call(this FREObject freObject, string methodName, ArrayList args)
        {
            uint resultPtr = 0;
            var  fre       = FreSharpHelper.Core.callMethod(freObject, methodName,
                                                            FreSharpHelper.ArgsToArgv(args), FreSharpHelper.GetArgsC(args), ref resultPtr);
            var ret    = new FREArray(fre);
            var status = (FreResultSharp)resultPtr;

            if (status == FreResultSharp.Ok)
            {
                return(ret);
            }
            Logger.Error($"cannot call method {methodName} of {freObject.toString()}", status, fre);
            return(null);
        }