如何在 boo (Rhino DSL) 中使用 C# 动态对象?
我正在使用 Rhino DSL,当我想将动态对象传递到脚本中时, boo 编译器抛出以下异常: BCE0019:Boo.Lang.Compiler.CompilerError:“Percent”不是“object”的成员。
我的 boo 代码:
Result = Run().Percent
C# Dsl Run 方法的基本代码:
dynamic myDynamicObject;
public dynamic Run()
{
//do somthing
return myDynamicObject;
}
- 在 Run 方法中,我将 myDynamicObject 设置为一个类继承自 DynamicObject 并重写 TrySetValue &尝试获取值方法
I am using Rhino DSL and when I want to pass a dynamic object into script,
boo compiler throws the Exception below:
BCE0019: Boo.Lang.Compiler.CompilerError: 'Percent' is not a member of 'object'.
my boo code:
Result = Run().Percent
C# Dsl Base code for Run method:
dynamic myDynamicObject;
public dynamic Run()
{
//do somthing
return myDynamicObject;
}
- in Run method I set myDynamicObject to a class that inherits from DynamicObject and override TrySetValue & TryGetValue method
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不确定“Percent”到底是如何被调用的,或者Rhino.DSL是否默认配置为ducky Boo,但您可以尝试“casting”为duck,例如
(myobject as duck).Percent
。请参阅 http://boo.codehaus.org/Duck+Typing 以供参考。Not sure how exactly 'Percent' is being called, or if Rhino.DSL is configured with ducky Boo as default, but you can try 'casting' as duck, e.g.
(myobject as duck).Percent
. See http://boo.codehaus.org/Duck+Typing for reference.