mirror of
https://github.com/farcasclaudiu/BlazorDeviceInterop.git
synced 2026-06-22 07:01:03 +03:00
Add project files.
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user