Beispiel #1
0
        public static LuaVMCall Decode(string str)
        {
            try
            {
                var      luaVMCall = new LuaVMCall();
                string[] arrayName = str.Split('(');
                luaVMCall.fnName = arrayName[0];

                arrayName[1] = arrayName[1].Replace(" ", "").Replace(")", "");
                string[] arrayParam = arrayName[1].Split(',');
                var      list       = new List <FieldParam>();
                for (int i = 0; i < arrayParam.Length; i++)
                {
                    string[] arraytype = arrayParam[i].Split(':');
                    if (arraytype.Length == 2)
                    {
                        var fieldParam = new FieldParam();
                        fieldParam.type  = arraytype[0];
                        fieldParam.value = arraytype[1];
                        list.Add(fieldParam);
                    }
                }
                luaVMCall.args = list.ToArray();
                return(luaVMCall);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Beispiel #2
0
        public static LuaVMCall Decode(string str)
        {
            var luaVMCall = new LuaVMCall();

            try
            {
                string[] arrayName = str.Split('(');
                luaVMCall.fnName = arrayName[0];

                arrayName[1] = arrayName[1].Replace(" ", "").Replace(")", "");
                var list = new List <FieldParam>();
                if (arrayName[1] != "")
                {
                    string[] arrayParam = arrayName[1].Split(',');
                    for (int i = 0; i < arrayParam.Length; i++)
                    {
                        int indexOf = arrayParam[i].IndexOf("\"");
                        if (indexOf != -1)
                        {
                            var fieldParam = new FieldParam();
                            fieldParam.type  = "String";
                            fieldParam.value = arrayParam[i].Replace("\"", "");
                            list.Add(fieldParam);
                        }
                        else
                        {
                            var fieldParam = new FieldParam();
                            fieldParam.type  = "UInt64";
                            fieldParam.value = arrayParam[i];
                            list.Add(fieldParam);
                        }
                    }
                }
                luaVMCall.args = list.ToArray();
                if (luaVMCall.fnName[0] == '_')
                {
                    throw new Exception($"{luaVMCall.fnName} is private function");
                }
                return(luaVMCall);
            }
            catch (Exception e)
            {
                throw e;
            }
        }