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

Created Unassigned: V8Engine.Evalute(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();
}
}
```

Viewing all articles
Browse latest Browse all 2297

Latest Images

Trending Articles





Latest Images