-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathParameterColor.cs
35 lines (27 loc) · 996 Bytes
/
ParameterColor.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
using System;
using Newtonsoft.Json;
namespace ConnectorLib.JSON;
public class ParameterColor : ParameterBase, IParameterValue
{
[JsonIgnore]
string IParameterValue.ID => ID;
[JsonIgnore]
string IParameterValue.Name => Name;
[JsonIgnore]
ParameterType IParameterValue.Type => Type;
/// <summary>
/// The color value.
/// </summary>
[JsonProperty(PropertyName = "value"), JsonConverter(typeof(HexColorConverter))]
public ParameterColorValue Value;
[JsonConstructor]
public ParameterColor(string name, string id, ParameterColorValue value) : base(name, id, ParameterType.HexColor)
=> Value = value;
[JsonConstructor]
public ParameterColor(string name, string id, string value) : base(name, id, ParameterType.HexColor)
{
if (!HexColorConverter.TryParse(value, out Value)) throw new ArgumentException("Unknown color code.", nameof(value));
}
[JsonIgnore]
object? IParameterValue.Value => Value;
}