globalItems for properties don't get updated? -
08-15-2005
, 05:58 PM
Hi,
I'm working on a scriptable project and I'd like to have a property
external to the scripting engine be readable as a global variable.
However, the property's get is only accessed the first time, from
GetGlobalInstance, and after that the global variable in the script is
constant, instead of reflecting the current value of the property.
Is there any way to do this without having to reference the property
through another object (e.g., making m_project a global and having the
script use m_project.NumTurns)?
I've tried boxing and of course that did nothing. I tried making
NumTurns be an object of a special class, that requests
m_project.NumTurns when its conversion operator is called, but VB.NET
doesn't support operator overloading, so that didn't help any.
For example:
/************************************************** *************/
scriptengine = new Microsoft.VisualBasic.Vsa.VsaEngine();
....
globalItem = (IVsaGlobalItem) items.CreateItem("NumTurns",
VsaItemType.AppGlobal, VsaItemFlag.None);
globalItem.TypeString = "System.Double";
.....
public object GetGlobalInstance(string name) {
switch(name) {
case "SimTime":
return m_project.NumTurns
default:
return null;
}
}
/************************************************** *************/