You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The documentation on ClrProxy was outdated but I was able to figure out how use it. The following is an example.
using YantraJS.Core;
using YantraJS.Core.Clr;
var synchronizationContext = new SynchronizationContext();
var context = new JSContext(synchronizationContext);
var calculator = new Calculator();
context["calculator"] = ClrProxy.From(calculator);
var a0 = await context.ExecuteAsync("calculator.add(1,1)"); // a0 = {2} JSNumber
var a1 = await context.ExecuteAsync("await calculator.addAsync(1,1);"); // a1 = {2} JSNumber
public class Calculator
{
public int Add(int x, int y)
{
return x + y;
}
public Task<int> AddAsync(int x, int y)
{
return Task.FromResult(x + y);
}
}
The text was updated successfully, but these errors were encountered:
@adiamante ClrProxy might be removed or will be changed, the correct way to supply Clr object would be to implement IJavaScriptObject or inheirt JavaScriptObject class. You can control what to export by using JSExport attribute. ClrProxy exports everything. I will be updating documentation soon.
Also using signature JSValue Method(in Arguments a) will be faster compared to using Clr types as arguments as there will be extra checks to convert JSValue to clr types. You can check this unit test on how to use it.
The documentation on ClrProxy was outdated but I was able to figure out how use it. The following is an example.
The text was updated successfully, but these errors were encountered: