-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAtomResult.cs
35 lines (29 loc) · 903 Bytes
/
AtomResult.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 System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EsotericDevZone.RuleBasedParser
{
public class AtomResult
{
public object Value { get; }
public string ErrorMessage { get; }
public bool Failed => ErrorMessage != null;
private AtomResult(object value, string errorMessage)
{
Value = value;
ErrorMessage = errorMessage;
}
public static AtomResult Atom(object value)
{
return new AtomResult(value, null);
}
public static AtomResult Error(string message)
{
return new AtomResult(null, message);
}
public override string ToString() => Failed ? $"AtomResult Error={ErrorMessage}"
: $"AtomResult Value={Value}";
}
}