Added bool/char typereaders
This commit is contained in:
@@ -26,6 +26,8 @@ namespace Discord.Commands
|
|||||||
_map = new CommandMap();
|
_map = new CommandMap();
|
||||||
_typeReaders = new ConcurrentDictionary<Type, TypeReader>
|
_typeReaders = new ConcurrentDictionary<Type, TypeReader>
|
||||||
{
|
{
|
||||||
|
[typeof(bool)] = new SimpleTypeReader<bool>(),
|
||||||
|
[typeof(char)] = new SimpleTypeReader<char>(),
|
||||||
[typeof(string)] = new SimpleTypeReader<string>(),
|
[typeof(string)] = new SimpleTypeReader<string>(),
|
||||||
[typeof(byte)] = new SimpleTypeReader<byte>(),
|
[typeof(byte)] = new SimpleTypeReader<byte>(),
|
||||||
[typeof(sbyte)] = new SimpleTypeReader<sbyte>(),
|
[typeof(sbyte)] = new SimpleTypeReader<sbyte>(),
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace Discord.Commands
|
|||||||
static PrimitiveParsers()
|
static PrimitiveParsers()
|
||||||
{
|
{
|
||||||
var parserBuilder = ImmutableDictionary.CreateBuilder<Type, Delegate>();
|
var parserBuilder = ImmutableDictionary.CreateBuilder<Type, Delegate>();
|
||||||
parserBuilder[typeof(string)] = (TryParseDelegate<string>)delegate(string str, out string value) { value = str; return true; };
|
parserBuilder[typeof(bool)] = (TryParseDelegate<bool>)bool.TryParse;
|
||||||
parserBuilder[typeof(sbyte)] = (TryParseDelegate<sbyte>)sbyte.TryParse;
|
parserBuilder[typeof(sbyte)] = (TryParseDelegate<sbyte>)sbyte.TryParse;
|
||||||
parserBuilder[typeof(byte)] = (TryParseDelegate<byte>)byte.TryParse;
|
parserBuilder[typeof(byte)] = (TryParseDelegate<byte>)byte.TryParse;
|
||||||
parserBuilder[typeof(short)] = (TryParseDelegate<short>)short.TryParse;
|
parserBuilder[typeof(short)] = (TryParseDelegate<short>)short.TryParse;
|
||||||
@@ -27,6 +27,12 @@ namespace Discord.Commands
|
|||||||
parserBuilder[typeof(decimal)] = (TryParseDelegate<decimal>)decimal.TryParse;
|
parserBuilder[typeof(decimal)] = (TryParseDelegate<decimal>)decimal.TryParse;
|
||||||
parserBuilder[typeof(DateTime)] = (TryParseDelegate<DateTime>)DateTime.TryParse;
|
parserBuilder[typeof(DateTime)] = (TryParseDelegate<DateTime>)DateTime.TryParse;
|
||||||
parserBuilder[typeof(DateTimeOffset)] = (TryParseDelegate<DateTimeOffset>)DateTimeOffset.TryParse;
|
parserBuilder[typeof(DateTimeOffset)] = (TryParseDelegate<DateTimeOffset>)DateTimeOffset.TryParse;
|
||||||
|
parserBuilder[typeof(char)] = (TryParseDelegate<char>)char.TryParse;
|
||||||
|
parserBuilder[typeof(string)] = (TryParseDelegate<string>)delegate (string str, out string value)
|
||||||
|
{
|
||||||
|
value = str;
|
||||||
|
return true;
|
||||||
|
};
|
||||||
_parsers = parserBuilder.ToImmutable();
|
_parsers = parserBuilder.ToImmutable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user