コード例 #1
0
        internal static T GetFromIndexMethod <T>(ILSObject obj, string methodName, string lsTypeName, int number, params string[] args)
        {
            // argument is 0-based
            number += 1;

            if (obj == null || !obj.IsValid || number <= 0)
            {
                return(default(T));
            }

            using (var index = LavishScript.Objects.NewObject("index:" + lsTypeName))
            {
                var allargs = PrefixArray(index.LSReference, args);

                if (!obj.ExecuteMethod(methodName, allargs))
                {
                    return(default(T));
                }

                using (var used = index.GetMember("Used"))
                {
                    // if it failed or we want one off the end, return
                    if (LavishScriptObject.IsNullOrInvalid(used) || used.GetValue <int>() < number)
                    {
                        return(default(T));
                    }
                }

                var member = GetIndexMember <T>(index, number);
                return(member);
            }
        }
コード例 #2
0
ファイル: Util.cs プロジェクト: isxGames/isxAionWrapper
        internal static T GetFromIndexMethod <T>(ILSObject Obj, string MethodName, string LSTypeName, int number, params string[] Args)
        {
            // argument is 0-based
            number += 1;

            if (Obj == null || !Obj.IsValid || number <= 0)
            {
                return(default(T));
            }

            LavishScriptObject Index = LavishScript.Objects.NewObject("index:" + LSTypeName);

            string[] allargs = PrefixArray <string>(Index.LSReference, Args);

            Obj.ExecuteMethod(MethodName, allargs);

            LavishScriptObject used = Index.GetMember("Used");

            // if it failed or we want one off the end, return
            if (LavishScriptObject.IsNullOrInvalid(used) || used.GetValue <int>() < number)
            {
                return(default(T));
            }

            return(GetIndexMember <T>(Index, number));
        }
コード例 #3
0
        /// <summary>
        /// Translate an index of a given LavishScript type returned from the given method on the given object to a List of a .NET datatype equivalent.
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="methodName"></param>
        /// <param name="lsTypeName"></param>
        /// <param name="args"></param>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public static List <T> GetListFromMethod <T>(this ILSObject obj, string methodName, string lsTypeName, params string[] args)
        {
            //string methodName = "GetListFromMethod";
            //Tracing.SendCallback(methodName, MethodName, LSTypeName);

            if (obj == null || !obj.IsValid)
            {
                return(null);
            }

            //Tracing.SendCallback(methodName, "Create new LSO of index. Type: ", LSTypeName);
            using (var index = LavishScript.Objects.NewObject("index:" + lsTypeName))
            {
                //Tracing.SendCallback(methodName, "Collapsing Args[]");

                string[] allargs;
                if (args.Length > 0)
                {
                    allargs = PrefixArray(index.LSReference, args);
                }
                else
                {
                    allargs    = new string[1];
                    allargs[0] = index.LSReference;
                }

                //Tracing.SendCallback(methodName, "Execute method, name: ", MethodName);
                if (!obj.ExecuteMethod(methodName, allargs))
                {
                    return(null);
                }

                //Tracing.SendCallback(methodName, "Get member Used");
                using (var used = index.GetMember("Used"))
                {
                    //Tracing.SendCallback(methodName, "LSO.IsNullOrInvalid (used)");
                    if (LavishScriptObject.IsNullOrInvalid(used))
                    {
                        return(null);
                    }
                }

                //Tracing.SendCallback(methodName, "IndexToList");
                var list = IndexToList <T>(index, lsTypeName);

                //Tracing.SendCallback(methodName, "Returning");
                return(list);
            }
        }
コード例 #4
0
ファイル: Util.cs プロジェクト: isxGames/isxAionWrapper
        internal static List <T> GetListFromMethod <T>(ILSObject Obj, string MethodName, string LSTypeName, params string[] Args)
        {
            if (Obj == null || !Obj.IsValid)
            {
                return(null);
            }

            LavishScriptObject Index = LavishScript.Objects.NewObject("index:" + LSTypeName);

            string[] allargs = PrefixArray <string>(Index.LSReference, Args);

            Obj.ExecuteMethod(MethodName, allargs);

            LavishScriptObject used = Index.GetMember("Used");

            if (LavishScriptObject.IsNullOrInvalid(used))
            {
                return(null);
            }

            return(IndexToList <T>(Index));
        }
コード例 #5
0
ファイル: Utils.cs プロジェクト: isxGames/ISXEQ2Wrapper
        internal static List <T> GetListFromMethod <T>(ILSObject obj, string methodName, string lsTypeName, params string[] args)
        {
            if (obj == null || !obj.IsValid)
            {
                return(null);
            }

            using (var index = LavishScript.Objects.NewObject("index:" + lsTypeName))
            {
                string[] allargs;
                if (args.Length > 0)
                {
                    allargs = PrefixArray(index.LSReference, args);
                }
                else
                {
                    allargs    = new string[1];
                    allargs[0] = index.LSReference;
                }

                if (!obj.ExecuteMethod(methodName, allargs))
                {
                    return(null);
                }

                using (var used = index.GetMember("Used"))
                {
                    if (LavishScriptObject.IsNullOrInvalid(used))
                    {
                        return(null);
                    }
                }

                var list = IndexToList <T>(index, lsTypeName);

                return(list);
            }
        }