c# - How to set function on ScriptScope -
how can set delegate on scriptscope under ironruby? tried above code got argumentexception when calling function.
scope.setvariable("import", new action<string>(dslimport)); import "data" also, how can utilize above code sending block callback c# code?
import "data" |f| f.foo = false end
i found way might not best, works. it's extension method scriptscope:
public static void setmethod(this scriptscope scope, string name, delegate method) { scope.setvariable(name + "__delegate", method); scope.engine.execute("def " + name + "(*args, &block)\nargs.push block if block != nil\n" + name + "__delegate.invoke(*args)\nend", scope); } c# .net clr ironruby
No comments:
Post a Comment