Beispiel #1
0
    static public System.Object getCSharpValue(System.Object obj, String key)
    {
        if (obj == null)
        {
            return(null);
        }
        Dictionary <string, SearchValueInfo> values = SearchDataInfo(obj);

        if (values.Count > 0)
        {
            if (values.ContainsKey(key))
            {
                LuaValueInfo value = values[key].luaValueInfo;
                if (value.valueStr == "Null")
                {
                    return(null);
                }
                else
                {
                    return(values[key].value);
                }
            }
            else
            {
                return(null);
            }
        }
        else
        {
            return(null);
        }
    }
        static int _g_get_valueStr(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                LuaValueInfo __cl_gen_to_be_invoked = (LuaValueInfo)translator.FastGetCSObj(L, 1);
                LuaAPI.lua_pushstring(L, __cl_gen_to_be_invoked.valueStr);
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
            return(1);
        }
        static int _s_set_isValue(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                LuaValueInfo __cl_gen_to_be_invoked = (LuaValueInfo)translator.FastGetCSObj(L, 1);
                __cl_gen_to_be_invoked.isValue = LuaAPI.lua_toboolean(L, 2);
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
            return(0);
        }
Beispiel #4
0
        static int _s_set_valueStr(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                LuaValueInfo gen_to_be_invoked = (LuaValueInfo)translator.FastGetCSObj(L, 1);
                gen_to_be_invoked.valueStr = LuaAPI.lua_tostring(L, 2);
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
            return(0);
        }
Beispiel #5
0
        static int _g_get_isValue(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                LuaValueInfo gen_to_be_invoked = (LuaValueInfo)translator.FastGetCSObj(L, 1);
                LuaAPI.lua_pushboolean(L, gen_to_be_invoked.isValue);
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
            return(1);
        }
 static public int get_valueStr(IntPtr l)
 {
     try {
         LuaValueInfo self = (LuaValueInfo)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.valueStr);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int constructor(IntPtr l)
 {
     try {
         LuaValueInfo o;
         o = new LuaValueInfo();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int set_valueType(IntPtr l)
 {
     try {
         LuaValueInfo  self = (LuaValueInfo)checkSelf(l);
         System.String v;
         checkType(l, 2, out v);
         self.valueType = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
    static int get_valueStr(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            LuaValueInfo obj = (LuaValueInfo)o;
            string       ret = obj.valueStr;
            LuaDLL.lua_pushstring(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index valueStr on a nil value"));
        }
    }
    static int set_isValue(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            LuaValueInfo obj  = (LuaValueInfo)o;
            bool         arg0 = LuaDLL.luaL_checkboolean(L, 2);
            obj.isValue = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index isValue on a nil value"));
        }
    }
    static int set_valueStr(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            LuaValueInfo obj  = (LuaValueInfo)o;
            string       arg0 = ToLua.CheckString(L, 2);
            obj.valueStr = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index valueStr on a nil value"));
        }
    }
    static int get_isValue(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            LuaValueInfo obj = (LuaValueInfo)o;
            bool         ret = obj.isValue;
            LuaDLL.lua_pushboolean(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index isValue on a nil value"));
        }
    }
        static int __CreateInstance(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
                if (LuaAPI.lua_gettop(L) == 1)
                {
                    LuaValueInfo __cl_gen_ret = new LuaValueInfo();
                    translator.Push(L, __cl_gen_ret);

                    return(1);
                }
            }
            catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
            return(LuaAPI.luaL_error(L, "invalid arguments to LuaValueInfo constructor!"));
        }
    static int _CreateLuaValueInfo(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 0)
            {
                LuaValueInfo obj = new LuaValueInfo();
                ToLua.PushObject(L, obj);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to ctor method: LuaValueInfo.New"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Beispiel #15
0
    static public Dictionary <string, SearchValueInfo> SearchDataInfo(System.Object obj)
    {
        Type t = obj.GetType();
        Dictionary <string, SearchValueInfo> values = new Dictionary <string, SearchValueInfo>();

        //判断是否是数组
        if (t.IsArray)
        {
            Array array = (Array)obj;
            int   i     = 0;
            foreach (object j in array)
            {
                var    value = j.ToString();
                string name  = "[" + i + "]";
                values.Add(name, new SearchValueInfo()
                {
                    value        = j,
                    key          = name,
                    luaValueInfo = new LuaValueInfo()
                    {
                        name      = name,
                        valueStr  = value.ToString(),
                        valueType = value.GetType().ToString(),
                        isValue   = checkIsValue(value.GetType())
                    }
                });
                i++;
            }
            return(values);
        }
        if (t.IsGenericType)
        {
            LuaIdeDebugInsTypeEnum insType = getInsType(t);
            if (insType == LuaIdeDebugInsTypeEnum.KeyValue)
            {
                return(getDictionaryValues(obj));
            }
            else if (insType == LuaIdeDebugInsTypeEnum.List)
            {
                return(getListValues(obj));
            }
        }
        if (t == typeof(ArrayList))
        {
            ArrayList arrayList = (ArrayList)obj;
            int       i         = 0;
            for (int k = 0; k < arrayList.Count; k++)
            {
                var    value = arrayList[k];
                string name  = "[" + i + "]";
                values.Add(name, new SearchValueInfo()
                {
                    value        = value,
                    key          = name,
                    luaValueInfo = new LuaValueInfo()
                    {
                        name      = name,
                        valueStr  = value.ToString(),
                        valueType = value.GetType().ToString(),
                        isValue   = checkIsValue(value.GetType())
                    }
                });
                i++;
            }
            return(values);
        }
        if (t == typeof(Hashtable))
        {
            Hashtable map     = (Hashtable)obj;
            ArrayList keyList = new ArrayList(map.Keys);
            for (int i = 0; i < keyList.Count; i++)
            {
                var keyValue  = keyList[i];
                var valeValue = map[keyValue];
                var info      = new LuaValueInfo();
                info.name      = "[" + keyList[i] + "]";
                info.valueStr  = valeValue.ToString();
                info.valueType = valeValue.GetType().ToString();
                info.isValue   = checkIsValue(valeValue.GetType());
                values.Add(info.name, new SearchValueInfo()
                {
                    key = info.name, value = valeValue, luaValueInfo = info
                });
            }
            return(values);
        }


        PropertyInfo[] pinfos = t.GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);
        foreach (PropertyInfo pinfo in pinfos)
        {
            try
            {
                if (pinfo.Name == "Item")
                {
                    continue;
                }

                var value = pinfo.GetValue(obj, null);

                var valueType = value.GetType();
                if (values.ContainsKey(pinfo.Name))
                {
                    int dd = 1;
                }
                values.Add(pinfo.Name, new SearchValueInfo()
                {
                    value        = value,
                    key          = pinfo.Name,
                    luaValueInfo = new LuaValueInfo()
                    {
                        name      = pinfo.Name,
                        valueStr  = value.ToString(),
                        valueType = valueType.ToString(),
                        isValue   = checkIsValue(valueType)
                    }
                });
            }
            catch (Exception e)
            {
                String error = e.Message;
                values.Add(pinfo.Name, new SearchValueInfo()
                {
                    value        = null,
                    key          = "",
                    luaValueInfo = new LuaValueInfo()
                    {
                        name      = pinfo.Name,
                        valueStr  = "Null",
                        valueType = " ",
                        isValue   = false
                    }
                });
            }
        }

        FieldInfo[] fields = t.GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance | BindingFlags.NonPublic);
        foreach (FieldInfo fi in fields)
        {
            try
            {
                string name      = fi.Name;
                object value     = fi.GetValue(obj);
                Type   valueType = null;
                if (value == null)
                {
                    values.Add(name, new SearchValueInfo()
                    {
                        key          = name,
                        value        = null,
                        luaValueInfo = new LuaValueInfo()
                        {
                            name      = name,
                            valueStr  = "Null",
                            valueType = " ",
                            isValue   = false
                        }
                    });
                }
                else
                {
                    valueType = value.GetType();
                    values.Add(name, new SearchValueInfo()
                    {
                        value        = value,
                        key          = name,
                        luaValueInfo = new LuaValueInfo()
                        {
                            name      = name,
                            valueStr  = value.ToString(),
                            valueType = valueType.ToString(),
                            isValue   = checkIsValue(valueType)
                        }
                    });
                }
            }
            catch (Exception e)
            {
                values.Add(fi.Name, new SearchValueInfo()
                {
                    value        = null,
                    key          = fi.Name,
                    luaValueInfo = new LuaValueInfo()
                    {
                        name      = fi.Name,
                        valueStr  = "Null",
                        valueType = " ",
                        isValue   = false
                    }
                });
            }
        }
        return(values);
    }