forked from chromelyapps/Chromely
-
Notifications
You must be signed in to change notification settings - Fork 0
Expose .NET class to JavaScript
mattkol edited this page Oct 25, 2017
·
2 revisions
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);
.....Chromely
- Getting Started
- Loading Html
- Demos
- Configuration
- Features
- Infrastructure
- Restful Resources
- Register Resource Assemblies
- Custom Local Resource Handling
- Custom Scheme Handling
- Expose .NET class to JavaScript
- Generic Message Routing
- Real-time with Websocket
- JavaScript Execution
- External Url Registration
- DevTool
Angular - React - Vue