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