Expose .NET class to JavaScript - chromelyapps/Chromely.Legacy GitHub Wiki
Applies Only to CefSharp apps
.NET object bounded to JavaScript details can be found on CefSharp site at section [How do you expose a .NET class to JavaScript?].
Chromely allows .NET objects exposed to JavaScript to be registered in ChromelyConfiguration. Registration is done by adding instance of ChromelyJsHandler to the IoC container. The ChromelyJsHandler:
public class ChromelyJsHandler
{
......
public string Key { get; private set; }
public string JsMethod { get; set; }
public object BoundObject { get; set; }
public object BindingOptions { get; set; }
public bool RegisterAsAsync { get; set; }
}
where RegisterAsAsync determines whether CefSharp RegisterAsyncJsObject or RegisterJsObject method is used for registration.
Following is an example of how registration is done:
ChromelyConfiguration config = ChromelyConfiguration()
.Create()
....
.RegisterJsHandler("boundControllerAsync", new CefSharpBoundObject(), null, true);
.RegisterJsHandler("boundControllerAsync2", new NewCefSharpBoundObject(), null, false);
.....