Hyperion
Hyperion copied to clipboard
TypeEx.IsHyperionPrimitive() checks could be much simplified
I've noticed that there are a lot of unnecessary checks:
public static bool IsHyperionPrimitive(this Type type)
{
return type == Int32Type ||
type == Int64Type ||
type == Int16Type ||
type == UInt32Type ||
type == UInt64Type ||
type == UInt16Type ||
type == ByteType ||
type == SByteType ||
type == DateTimeType ||
type == BoolType ||
type == StringType ||
type == GuidType ||
type == FloatType ||
type == DoubleType ||
type == DecimalType ||
type == CharType;
}
But we could replace most of these checks with simple type.IsPrimitive
check, like this:
public static bool IsHyperionPrimitive(this Type type)
{
return type.IsPrimitive
|| type == StringType
|| type == GuidType
|| type == DateTimeType
|| type == DecimalType;
}
Also this answer might be useful - https://stackoverflow.com/a/16589255
I like this idea.