Context: ClearScript, JScript, C#, Windows, Azure
In my ClearScript-enabled projects, I have a Dictionary<string,object>
that I use for passing data into, around inside and back out of evaluated scripts.
On the C# side I have
static Dictionary<string, object> Settings = new Dictionary<string, object>();
and then later on
JSengine = new JScriptEngine(WindowsScriptEngineFlags.EnableDebugging | WindowsScriptEngineFlags.EnableJITDebugging);
and
JSengine.AddHostObject("CSSettings", Settings);
On the JScript side I have things like
CSSettings.Add("your API key", CSConfig.Retrieve("api.key"));
for setting values.
The challenge at the moment is updating a value in the Dictionary. The following works
CSSettings.Item("id") = Wfm_AccNumber;
it's just that it's non-standard JScript. What's more the JSHint tool that I'm using inside of Notepad++ complains.
I could do a .Remove()
before the .Add()
, I suppose but is there a better way?