Files
BlazorDeviceInterop/BlazorDeviceInterop.Components/InteropObject.cs
T
Bernard Darnton 9576c5aa5b Add project files.
2020-10-12 06:03:49 +13:00

23 lines
649 B
C#

using Microsoft.JSInterop;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace BlazorDeviceInterop.Components
{
public abstract class InteropObject
{
protected JsRuntimeObjectRef _jsObjRef;
[JsonPropertyName("__jsObjRefId")]
public int JsObjectRefId { get { return _jsObjRef.JsObjectRefId; } }
public async Task BindToJsRuntime(IJSRuntime jsRuntime)
{
_jsObjRef = await CreateJsObjectRef(jsRuntime);
_jsObjRef.JSRuntime = jsRuntime;
}
protected abstract Task<JsRuntimeObjectRef> CreateJsObjectRef(IJSRuntime jsRuntime);
}
}