本文整理匯總了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);
}