-
Notifications
You must be signed in to change notification settings - Fork 9.9k
/
DotNetInvocationResult.cs
55 lines (49 loc) · 1.69 KB
/
DotNetInvocationResult.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
45
46
47
48
49
50
51
52
53
54
55
using System;
namespace Microsoft.JSInterop.Infrastructure
{
/// <summary>
/// Result of a .NET invocation that is returned to JavaScript.
/// </summary>
public readonly struct DotNetInvocationResult
{
/// <summary>
/// Constructor for a failed invocation.
/// </summary>
/// <param name="exception">The <see cref="System.Exception"/> that caused the failure.</param>
/// <param name="errorKind">The error kind.</param>
public DotNetInvocationResult(Exception exception, string? errorKind)
{
Result = default;
Exception = exception ?? throw new ArgumentNullException(nameof(exception));
ErrorKind = errorKind;
Success = false;
}
/// <summary>
/// Constructor for a successful invocation.
/// </summary>
/// <param name="result">The result.</param>
public DotNetInvocationResult(object? result)
{
Result = result;
Exception = default;
ErrorKind = default;
Success = true;
}
/// <summary>
/// Gets the <see cref="System.Exception"/> that caused the failure.
/// </summary>
public Exception? Exception { get; }
/// <summary>
/// Gets the error kind.
/// </summary>
public string? ErrorKind { get; }
/// <summary>
/// Gets the result of a successful invocation.
/// </summary>
public object? Result { get; }
/// <summary>
/// <see langword="true"/> if the invocation succeeded, otherwise <see langword="false"/>.
/// </summary>
public bool Success { get; }
}
}