You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thank you for reporting this issue. I think dynamic type should also be supported by current ReoScript. But when I did the test about your issue I found another bug in ReoScript's DirectAccess mode. If you using DirectAccess to access a field of type (whether it is dynamic or not) from your script, you may always get a null value.
This bug is that current ReoScript always capitalizes the first letter of field's name, so there is no field will be found. For example:
in .NET:
class T {
public int a = 10;
}
srm["obj"] = new T();
in script:
console.log(obj.a); // get null since ReoScript tries to find the field called 'A'.
This bug will be fixed in next release.
Please try to use a .NET type in script by the following ways:
If your type inherits from ObjectValue, put property into ObjectValue like:
in .NET:
class T : ObjectValue { }
dynamic obj = new T();
obj["a"] = 10;
srm["obj"] = obj;
in script:
console.log(obj.a); // 10
If your type does not inherit from ObjectValue, you need use DirectAccess mode.
in .NET:
class T {
public int A { get; set; }
}
dynamic obj = new T();
obj.A = 10;
srm.WorkMode |= MachineWorkMode.AllowDirectAccess; // enable DirectAccess
srm["obj"] = obj;
Brad you are right, ExpandoObject class is not be supported by current ReoScript. I found that ExpandoObject implements the IDictionary<string, object> interface so I have an idea to resolve this issue. Let me fix this in next version!
Brad you're welcome! I just released the version 1.3 that is supported to access properties from IDictionary<string, object> interface, and the enumeration by using for...in syntax is also supported. I've test it in VisualStudio 2012 and .NET Framwork 4.5.
If you have other problems, please let me know. Thanks for a good suggestion again!
Activity
jingwood commentedon Jun 14, 2013
Hi Brad,
Thank you for reporting this issue. I think dynamic type should also be supported by current ReoScript. But when I did the test about your issue I found another bug in ReoScript's DirectAccess mode. If you using DirectAccess to access a field of type (whether it is dynamic or not) from your script, you may always get a null value.
This bug is that current ReoScript always capitalizes the first letter of field's name, so there is no field will be found. For example:
in .NET:
in script:
This bug will be fixed in next release.
Please try to use a .NET type in script by the following ways:
If your type inherits from ObjectValue, put property into ObjectValue like:
in .NET:
in script:
If your type does not inherit from ObjectValue, you need use DirectAccess mode.
in .NET:
in script:
Hope it is useful to you!
Jing Lu
bradodarb commentedon Jun 14, 2013
Thank you for the prompt reply, Jing!
I am using code similar to your 2nd example.
The problem is using a property added to the dynamic object:
This works accessing A from a script
This does not work
When I debug the script execution,
comes back as
(as does obj.property).
*however
,
and
All return null.
I already have c#, python and ruby scripting capabilities built into my application and I would love to get this working with reoscript!
jingwood commentedon Jun 15, 2013
Brad you are right, ExpandoObject class is not be supported by current ReoScript. I found that ExpandoObject implements the
IDictionary<string, object>interface so I have an idea to resolve this issue. Let me fix this in next version!bradodarb commentedon Jun 15, 2013
Jing, my apologies for not mentioning the ExpandoObject explicitly in my original post.
You are correct, it does implement IDictionary<string, object>.
I am really looking forward to the next version!
Release v1.3
jingwood commentedon Jun 17, 2013
Brad you're welcome! I just released the version 1.3 that is supported to access properties from
IDictionary<string, object>interface, and the enumeration by using for...in syntax is also supported. I've test it in VisualStudio 2012 and .NET Framwork 4.5.If you have other problems, please let me know. Thanks for a good suggestion again!
bradodarb commentedon Jun 26, 2013
Verified the new release does indeed fix the ExpandoObject issue.
Thanks again Mr. Lu!