本文整理汇总了C#中NLua.LuaTable.IsArray方法的典型用法代码示例。如果您正苦于以下问题:C# LuaTable.IsArray方法的具体用法?C# LuaTable.IsArray怎么用?C# LuaTable.IsArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NLua.LuaTable
的用法示例。
在下文中一共展示了LuaTable.IsArray方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BitwiseOr
public object BitwiseOr(LuaTable table)
{
// First of all, check it's actually an array
int size;
if (!table.IsArray(out size) || size == 0)
{
throw new InvalidOperationException("Specified table is not an array");
}
// Get the length
int result = -1;
Type type = null;
// Create the array
foreach (object key in table.Keys)
{
if (result < 0)
{
result = (int)table[key];
type = table[key].GetType();
continue;
}
result |= (int)table[key];
}
// Return it
return Enum.ToObject(type, result);
}
示例2: TableToArray
public object[] TableToArray(LuaTable table)
{
// First of all, check it's actually an array
int size;
if (!table.IsArray(out size))
{
throw new InvalidOperationException("Specified table is not an array");
}
// Get the length
var arr = new object[size];
// Create the array
foreach (var key in table.Keys)
{
var index = Convert.ToInt32(key) - 1;
arr[index] = table[key];
}
// Return it
return arr;
}
示例3: SpecializeType
public Type SpecializeType(Type baseType, LuaTable argTable)
{
int cnt;
if (!argTable.IsArray(out cnt)) throw new ArgumentException("Table is not an array", "argTable");
Type[] typeArgs = new Type[cnt];
for (int i = 0; i < cnt; i++)
{
object obj = argTable[i + 1];
if (obj is LuaTable) obj = (obj as LuaTable)["_type"];
if (!(obj is Type)) throw new ArgumentException("Item in table is not a Type", $"argTable[{i + 1}]");
typeArgs[i] = obj as Type;
}
return baseType.MakeGenericType(typeArgs);
}