linq - Cannot call .Count() IEnumerable extensions from lua script using nula -
so have little lua script want call extension method on ienumerable collection.
require ''clrpackage'' import ''system.collections.generic'' import ''system.linq'' import ''my.namespace.containing.audiomarker'' local audiomarkerswithoffset = getaudiomarkers(); local numberofmarkers = audiomarkerswithoffset.count();
so getaudiomarkers() c# method returning ienumerable of audiomarker objects. doing luanet.each work fine , able iterate every element of collection. need count of collection , calling .count() following error: nlua.exceptions.luascriptexception: [string "chunk"]:54: attempt call field 'count' (a string value).
by way, know nlua don't need pre-register types used them try , without last import audiomarker, got same result.
i'm doing wrong cannot seem find documentation on web regarding issue.
i have been trying use ienumerable<t>.tolist()
extension method myself, testing reveals nlua has problems generic methods.. calling method of form void func<t>(<t> arg)
possible if register lua function (lua.registerfunction
), if try call same method on object present in lua state, "attempt call method..." error. also, method of form void func<t>(ienumerable<t> arg)
fail in both cases nullreferenceexception
, "attempt call method..." error, respectively.
another point is, if want call c# extension methods lua, need ":" syntax, not "." (see nlua "testextensionmethods" unit test).
Comments
Post a Comment