Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

New Post: .Net Default Property Recognition

0
0
The expectation is the same as it is in the .Net framework. Consider following example:
Using engine As New V8ScriptEngine(V8ScriptEngineFlags.DisableGlobalMembers, V8ScriptEngineFlags.EnableDebugging, 9222)
            engine.AddHostType("console", GetType(Console))
            engine.AddHostObject("testDict", New Dictionary(Of String, String) From {{"a", "1"}})
            engine.Evaluate("console.WriteLine('testElement = {0};', testDict.Item('a')); console.WriteLine('');")
End Using
In the code above I'm simply outputting a value of the dictionary item found by key, testDict.Item('a'). Note that .Item is a default property in case of dictionary, so I was expecting I can do the following (the only difference is how I'm trying to access the dictionary item):
...
engine.Evaluate("console.WriteLine('testElement = {0};', testDict('a')); console.WriteLine('');")
...
For me this is not a big deal in particular, it's just the observation of behavior vs. the expectation on my end.

Viewing all articles
Browse latest Browse all 2297

Latest Images

Trending Articles





Latest Images