我在文本文件application.txt
application {
title "Template application"
settings {}
}
我像这样评估
def application = new MainForm()
Binding binding = new Binding()
binding.setVariable("application", application)
GroovyShell shell = new GroovyShell(binding)
evaluate(new File("application.txt"))
我的MainForm
对象包含这样的代码
class MainForm {
def call(Closure cl) {
cl.delegate = this
cl()
}
def methodMissing(String name, args) {
if (name == "title") {
....
} else {
....
}
}
}
但是我决定摆脱文本文件中的u {application {}
工具,只留下简单的
title "Template application"
settings {}
我使用的代码不再起作用,抛出missing method
异常。
def application = new MainForm()
Binding binding = new Binding()
binding.setVariable("application", application)
GroovyShell shell = new GroovyShell(binding)
evaluate(new File("application.txt"))
我应该如何更改此代码以使我的新方法有效? (基本上我想评估application
)