Ready for the first beta release. #105
@ -2,45 +2,73 @@
|
|||||||
|
|
|||||||
|
|
||||||
public static class TypeParsers
|
public static class TypeParsers
|
||||||
{
|
{
|
||||||
public static bool CanParse(object? obj) => obj is not null && obj is sbyte or byte or short or ushort or int
|
public static bool CanParse(object? obj) => obj is not null && obj is bool or sbyte or byte or short or ushort
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
or uint or long or ulong or Int128 or UInt128 or nint or nuint or Half or float or double or decimal
|
or int or uint or long or ulong or Int128 or UInt128 or nint or nuint or Half or float or double or decimal
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
or char or DateOnly or DateTime or DateTimeOffset or Guid or TimeOnly or TimeSpan;
|
or char or DateOnly or DateTime or DateTimeOffset or Guid or TimeOnly or TimeSpan;
|
||||||
public static bool CanParse(Type type) => type == typeof(sbyte) || type == typeof(byte) || type == typeof(short)
|
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
|| type == typeof(ushort) || type == typeof(int) || type == typeof(uint) || type == typeof(long)
|
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
|| type == typeof(ulong) || type == typeof(Int128) || type == typeof(UInt128) || type == typeof(nint)
|
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
|| type == typeof(nuint) || type == typeof(Half) || type == typeof(float) || type == typeof(double)
|
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
|| type == typeof(decimal) || type == typeof(char) || type == typeof(DateOnly) || type == typeof(DateTime)
|
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
|| type == typeof(DateTimeOffset) || type == typeof(Guid) || type == typeof(TimeOnly)
|
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
|| type == typeof(TimeSpan);
|
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
public static object ParseAll(string msg)
|
public static object ParseAll(string msg)
|
||||||
{
|
{
|
||||||
if (TryParse(msg, out sbyte int8)) return int8;
|
if (TryParseBool(msg, out bool resBool)) return resBool;
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
if (TryParse(msg, out byte uInt8)) return uInt8;
|
else if (TryParse(msg, out sbyte int8)) return int8;
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
if (TryParse(msg, out short int16)) return int16;
|
else if (TryParse(msg, out byte uInt8)) return uInt8;
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
if (TryParse(msg, out ushort uInt16)) return uInt16;
|
else if (TryParse(msg, out short int16)) return int16;
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
if (TryParse(msg, out int int32)) return int32;
|
else if (TryParse(msg, out ushort uInt16)) return uInt16;
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
if (TryParse(msg, out uint uInt32)) return uInt32;
|
else if (TryParse(msg, out int int32)) return int32;
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
if (TryParse(msg, out long int64)) return int64;
|
else if (TryParse(msg, out uint uInt32)) return uInt32;
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
if (TryParse(msg, out ulong uInt64)) return uInt64;
|
else if (TryParse(msg, out long int64)) return int64;
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
if (TryParse(msg, out Int128 int128)) return int128;
|
else if (TryParse(msg, out ulong uInt64)) return uInt64;
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
if (TryParse(msg, out UInt128 uInt128)) return uInt128;
|
else if (TryParse(msg, out Int128 int128)) return int128;
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
if (TryParse(msg, out nint intPtr)) return intPtr;
|
else if (TryParse(msg, out UInt128 uInt128)) return uInt128;
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
if (TryParse(msg, out nuint uIntPtr)) return uIntPtr;
|
else if (TryParse(msg, out nint intPtr)) return intPtr;
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
if (TryParse(msg, out Half float16)) return float16;
|
else if (TryParse(msg, out nuint uIntPtr)) return uIntPtr;
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
if (TryParse(msg, out float float32)) return float32;
|
else if (TryParse(msg, out Half float16)) return float16;
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
if (TryParse(msg, out double float64)) return float64;
|
else if (TryParse(msg, out float float32)) return float32;
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
if (TryParse(msg, out decimal float128)) return float128;
|
else if (TryParse(msg, out double float64)) return float64;
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
if (TryParse(msg, out char resChar)) return resChar;
|
else if (TryParse(msg, out decimal float128)) return float128;
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
if (TryParse(msg, out DateOnly dateOnly)) return dateOnly;
|
else if (TryParse(msg, out char resChar)) return resChar;
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
if (TryParse(msg, out DateTime dateTime)) return dateTime;
|
else if (TryParse(msg, out DateOnly dateOnly)) return dateOnly;
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
if (TryParse(msg, out DateTimeOffset dateTimeOffset)) return dateTimeOffset;
|
else if (TryParse(msg, out DateTime dateTime)) return dateTime;
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
if (TryParse(msg, out Guid guid)) return guid;
|
else if (TryParse(msg, out DateTimeOffset dateTimeOffset)) return dateTimeOffset;
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
if (TryParse(msg, out TimeOnly timeOnly)) return timeOnly;
|
else if (TryParse(msg, out Guid guid)) return guid;
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
if (TryParse(msg, out TimeSpan timeSpan)) return timeSpan;
|
else if (TryParse(msg, out TimeOnly timeOnly)) return timeOnly;
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
|
else if (TryParse(msg, out TimeSpan timeSpan)) return timeSpan;
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
return msg;
|
else return msg;
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool TryParseBool(string msg, out bool result)
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
|
{
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
|
string trimmed = msg.Trim().ToLower();
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
|
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
|
string[] trues = new string[]
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
|
{
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
|
"t",
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
|
"true",
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
|
"1",
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
|
"y",
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
|
"yes"
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
|
},
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
|
falses = new string[]
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
|
{
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
|
"f",
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
|
"false",
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
|
"0",
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
|
"n",
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
|
"no"
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
|
};
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
|
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
|
foreach (string t in trues) if (trimmed == t)
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
|
{
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
|
result = true;
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
|
return true;
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
|
}
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
|
foreach (string f in falses) if (trimmed == f)
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
|
{
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
|
result = false;
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
|
return true;
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
|
}
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
|
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
|
result = false;
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
|
return false;
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
|
}
|
||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
|
|||||||
public static bool TryParse<T>(string msg, out T? result) where T : IParsable<T>
|
public static bool TryParse<T>(string msg, out T? result) where T : IParsable<T>
|
||||||
=> T.TryParse(msg, null, out result);
|
=> T.TryParse(msg, null, out result);
|
||||||
}
|
}
|
||||||
|
|||||||
|
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
Synchronize this file with the other TypeParsers class in the shell. Synchronize this file with the other TypeParsers class in the shell.
This has been completed now. This has been completed now.
This has been completed now. This has been completed now.
|
|||||||
Synchronize this file with the other TypeParsers class in the shell.
Synchronize this file with the other TypeParsers class in the shell.
This has been completed now.
This has been completed now.