-
Notifications
You must be signed in to change notification settings - Fork 243
/
JsiiMethodAttribute.cs
38 lines (32 loc) · 1.18 KB
/
JsiiMethodAttribute.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
using Amazon.JSII.JsonModel.Spec;
using Newtonsoft.Json;
using System;
namespace Amazon.JSII.Runtime.Deputy
{
[AttributeUsage(AttributeTargets.Method)]
public sealed class JsiiMethodAttribute : Attribute
{
public JsiiMethodAttribute(
string name,
string? returnsJson = null,
string? parametersJson = null,
bool isAsync = false,
// Unused, retained for backwards-compatibility
bool isOverride = false)
{
Name = name ?? throw new ArgumentNullException(nameof(name));
Returns = returnsJson == null
? null
: JsonConvert.DeserializeObject<OptionalValue>(returnsJson);
Parameters = parametersJson == null
? Array.Empty<Parameter>()
: JsonConvert.DeserializeObject<Parameter[]>(parametersJson)
?? throw new ArgumentException("Invalid JSON descriptor", nameof(parametersJson));
IsAsync = isAsync;
}
public string Name { get; }
public OptionalValue? Returns { get; }
public Parameter[] Parameters { get; }
public bool IsAsync { get; }
}
}