mirror of https://github.com/oliverbooth/X10D
(#14) Pattern-match IsEnum property on typeof(T)
This commit is contained in:
parent
3d44132865
commit
af3dfaa623
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
@ -134,9 +134,7 @@ namespace X10D
|
||||||
throw new ArgumentException(Resource.EnumParseEmptyStringException, nameof(value));
|
throw new ArgumentException(Resource.EnumParseEmptyStringException, nameof(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
var type = typeof(T);
|
if (typeof(T) is not { IsEnum: true } type)
|
||||||
|
|
||||||
if (!type.IsEnum)
|
|
||||||
{
|
{
|
||||||
throw new ArgumentException(Resource.EnumParseNotEnumException);
|
throw new ArgumentException(Resource.EnumParseNotEnumException);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue