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

Commented Issue: V8ScriptEngine.Evaluate(V8Script) returns HostObject for .net objects [16]

$
0
0
```
public class TestItem
{
public string Str { get; set; }
}

class Program
{
static void Main(string[] args)
{
using (var runtime = new V8Runtime())
using (var engine = runtime.CreateScriptEngine())
{
engine.AddHostObject("test", new TestItem());

string scriptCode = "test";
V8Script compiledScript = runtime.Compile(scriptCode);

object result = engine.Evaluate(scriptCode); //TestItem type
object resultFromCompiled = engine.Evaluate(compiledScript); // HostObject type

if (!result.Equals(resultFromCompiled)) // Different type of objects.
throw new ApplicationException();
}

Console.ReadLine();
}
}
```
Comments: Thanks!

Viewing all articles
Browse latest Browse all 2297

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>