예제 #1
0
 public LuaObject(object value)
 {
     if (value == null)
     {
         type = ELuaItemType.Nil;
     }
     else
     {
         Type valueType = value.GetType();
         if (valueType.IsArray ||
             (valueType.IsGenericType && valueType.GetGenericTypeDefinition() == typeof(List <>)))
         {
             type        = ELuaItemType.Table;
             value_table = new LuaTable();
             foreach (var item in (IList)value)
             {
                 value_table.AddItem(item);
             }
         }
         else
         {
             if (valueType == typeof(int))
             {
                 type      = ELuaItemType.Int;
                 value_int = (int)value;
             }
             else if (valueType == typeof(long))
             {
                 type       = ELuaItemType.Long;
                 value_long = (long)value;
             }
             else if (valueType == typeof(float))
             {
                 type        = ELuaItemType.Float;
                 value_float = (float)value;
             }
             else if (valueType == typeof(bool))
             {
                 type          = ELuaItemType.Boolean;
                 value_boolean = (bool)value;
             }
             else if (valueType == typeof(string))
             {
                 value_str = (string)value;
                 if (value_str.IndexOf("function") >= 0 && value_str.IndexOf("end") >= 0)
                 {
                     type = ELuaItemType.Function;
                 }
                 else
                 {
                     type = ELuaItemType.String;
                 }
             }
             else if (valueType == typeof(LuaTable))
             {
                 type        = ELuaItemType.Table;
                 value_table = (LuaTable)value;
             }
             else
             {
                 type = ELuaItemType.Nil;
             }
         }
     }
 }
예제 #2
0
 public LuaObject()
 {
     type = ELuaItemType.nil;
 }
예제 #3
0
 public LuaObject(LuaTable value)
 {
     type        = ELuaItemType.Table;
     value_table = value;
 }
예제 #4
0
 public LuaObject(bool value)
 {
     type          = ELuaItemType.Boolean;
     value_boolean = value;
 }
예제 #5
0
 public LuaObject(int value)
 {
     type      = ELuaItemType.Num;
     value_num = value;
 }
예제 #6
0
 public LuaObject(string value)
 {
     type      = ELuaItemType.String;
     value_str = value;
 }