Class BaseJavaScriptInterop

Helper class that simplifies calling JavaScript functions in a WebView document. Helps with formatting calls using ExecuteScriptAsync() and properly formatting/encoding parameters.

Recommend that you subclass this object for your application and then implement wrapper methods around each interop call you make into the JavaScript document

Operations are applied to the BaseInvocationTarget which is the base object that operations are run on. This can be the window. or any globally accessibly object ie. window.textEditor..

You can use Invoke, Set, Get to access object properties, or you can use ExecuteScriptAsync to fire raw requests.

Parameterize helps with encoding parameters when calling methods and turning them into string parseable values using JSON.

System.Object
  Westwind.WebView.Wpf.BaseJavaScriptInterop
public class BaseJavaScriptInterop : object

Class Members

MemberDescription

Constructor

Creates an instance of this interop object to call JavaScript functions in the loaded DOM document.

CallMethodWithJson

Calls a method on the TextEditor in JavaScript a single JSON encoded value or object. The receiving function should expect a JSON object and parse it.

This version returns no result value.

public Task CallMethodWithJson(string method,     object parameter)

CallMethodWithJson

Calls a method on the TextEditor in JavaScript a single JSON encoded value or object. The receiving function should expect a JSON object and parse it.

public Task CallMethodWithJson(string method,     object parameter)

DeserializeObject

Helper method to deserialize json content

public static TResult DeserializeObject(string json)

ExecuteScriptAsync

Calls a method on the TextEditor in JavaScript a single JSON encoded value or object. The receiving function should expect a JSON object and parse it.

public Task ExecuteScriptAsync(string script)

ExecuteScriptAsyncWithResult

Calls a method on the TextEditor in JavaScript a single JSON encoded value or object.

public Task ExecuteScriptAsyncWithResult(string script)

Get

Gets a property from the window.textEditor object

public Task Get(string propertyName)

Invoke

Calls a method with simple parameters: String, number, boolean This version returns no results.

public Task Invoke(string method,     Object[] parameters)

Invoke

Calls a method with simple or no parameters: string, boolean, numbers

public Task Invoke(string method,     Object[] parameters)

Parameterize

public string Parameterize(Object[] parameters)

SerializeObject

Helper method that consistently serializes JavaScript with Camelcase

public static string SerializeObject(object data)

Set

Sets a property on the editor by name

public Task Set(string propertyName,     object value)

BaseInvocationTargetString

WebBrowser

WebBrowser instance that the interop object operates on

Requirements

Namespace: Westwind.WebView.Wpf
Assembly: markdownmonster.exe

© West Wind Technologies, 2016-2024 • Updated: 11/23/21
Comment or report problem with topic