-
Notifications
You must be signed in to change notification settings - Fork 105
/
Copy pathBooleanString.cs
54 lines (49 loc) · 1.28 KB
/
BooleanString.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
using Newtonsoft.Json;
using OmniSharp.Extensions.LanguageServer.Protocol.Serialization.Converters;
namespace OmniSharp.Extensions.LanguageServer.Protocol.Models
{
[JsonConverter(typeof(BooleanStringConverter))]
public struct BooleanString
{
private string _string;
private bool? _bool;
public BooleanString(string value)
{
_string = value;
_bool = null;
}
public BooleanString(bool value)
{
_string = null;
_bool = value;
}
public bool IsString => _string != null;
public string String
{
get => _string;
set
{
_string = value;
_bool = null;
}
}
public bool IsBool => _bool.HasValue;
public bool Bool
{
get => _bool.HasValue && _bool.Value;
set
{
String = null;
_bool = value;
}
}
public static implicit operator BooleanString(string value)
{
return new BooleanString(value);
}
public static implicit operator BooleanString(bool value)
{
return new BooleanString(value);
}
}
}