-
Notifications
You must be signed in to change notification settings - Fork 9.8k
/
JSInProcessObjectReference.cs
44 lines (37 loc) · 1.47 KB
/
JSInProcessObjectReference.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Diagnostics.CodeAnalysis;
namespace Microsoft.JSInterop.Implementation
{
/// <summary>
/// Implements functionality for <see cref="IJSInProcessObjectReference"/>.
/// </summary>
public class JSInProcessObjectReference : JSObjectReference, IJSInProcessObjectReference
{
private readonly JSInProcessRuntime _jsRuntime;
/// <summary>
/// Inititializes a new <see cref="JSInProcessObjectReference"/> instance.
/// </summary>
/// <param name="jsRuntime">The <see cref="JSInProcessRuntime"/> used for invoking JS interop calls.</param>
/// <param name="id">The unique identifier.</param>
protected internal JSInProcessObjectReference(JSInProcessRuntime jsRuntime, long id) : base(jsRuntime, id)
{
_jsRuntime = jsRuntime;
}
/// <inheritdoc />
public TValue Invoke<TValue>(string identifier, params object?[]? args)
{
ThrowIfDisposed();
return _jsRuntime.Invoke<TValue>(identifier, Id, args);
}
/// <inheritdoc />
public void Dispose()
{
if (!Disposed)
{
Disposed = true;
_jsRuntime.InvokeVoid("DotNet.jsCallDispatcher.disposeJSObjectReferenceById", Id);
}
}
}
}