sockscape/server/Libraries/Glove/INI/Value.cs

44 lines
1,022 B
C#
Raw Normal View History

2017-06-07 21:02:29 +00:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
2017-07-22 19:27:41 +00:00
namespace Glove.INI {
2017-06-07 21:02:29 +00:00
public class Value {
2017-08-21 21:03:32 +00:00
private readonly string Raw;
2017-06-07 21:02:29 +00:00
public Value(string raw) {
Raw = raw;
}
public string Str
=> this;
2017-06-07 21:02:29 +00:00
public Int32 Int
=> this;
public double Dbl
=> this;
2017-09-08 21:06:55 +00:00
public bool Bool
=> this;
public static implicit operator string(Value value)
=> value.Raw;
2017-06-07 21:02:29 +00:00
public static implicit operator bool(Value value)
=> Boolean.TryParse(value.Raw, out bool retval) && retval;
public static implicit operator Int32(Value value)
=> Int32.TryParse(value.Raw, out Int32 retval)
2017-06-07 21:02:29 +00:00
? retval
: 0;
public static implicit operator double(Value value)
=> Double.TryParse(value.Raw, out double retval)
2017-06-07 21:02:29 +00:00
? retval
: 0;
}
}