Hyperion icon indicating copy to clipboard operation
Hyperion copied to clipboard

TypeEx.IsHyperionPrimitive() checks could be much simplified

Open aienabled opened this issue 7 years ago • 1 comments

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

aienabled avatar May 25 '17 06:05 aienabled

I like this idea.

Aaronontheweb avatar Oct 25 '18 21:10 Aaronontheweb