本文整理汇总了C#中NLua.ObjectTranslator.MatchParameters方法的典型用法代码示例。如果您正苦于以下问题:C# ObjectTranslator.MatchParameters方法的具体用法?C# ObjectTranslator.MatchParameters怎么用?C# ObjectTranslator.MatchParameters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NLua.ObjectTranslator
的用法示例。
在下文中一共展示了ObjectTranslator.MatchParameters方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MatchOperator
static int MatchOperator (LuaState luaState, string operation, ObjectTranslator translator)
{
var validOperator = new MethodCache ();
object target = GetTargetObject (luaState, operation, translator);
if (target == null) {
translator.ThrowError (luaState, "Cannot call " + operation + " on a nil object");
LuaLib.LuaPushNil (luaState);
return 1;
}
Type type = target.GetType ();
var operators = type.GetMethods (operation, BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static);
foreach (var op in operators) {
bool isOk = translator.MatchParameters (luaState, op, ref validOperator);
if (!isOk)
continue;
object result;
if (op.IsStatic)
result = op.Invoke (null, validOperator.args);
else
result = op.Invoke (target, validOperator.args);
translator.Push (luaState, result);
return 1;
}
translator.ThrowError (luaState, "Cannot call (" + operation + ") on object type " + type.Name);
LuaLib.LuaPushNil (luaState);
return 1;
}