System.Runtime.Serialization.Plists.Extensions.IsPrimitiveOrEnum C# (CSharp) Method

IsPrimitiveOrEnum() public static method

Gets a value indicating whether the specified type is an enum or primitive or semi-primitive (e.g., string) type.
public static IsPrimitiveOrEnum ( this type ) : bool
type this The type to check.
return bool
        public static bool IsPrimitiveOrEnum(this Type type)
        {
            if (type == null)
            {
                throw new ArgumentNullException("type", "type cannot be null.");
            }

            bool result = true;

            if (!type.IsEnum
                && Type.GetTypeCode(type) == TypeCode.Object
                && !typeof(Guid).IsAssignableFrom(type)
                && !typeof(TimeSpan).IsAssignableFrom(type)
                && !typeof(byte[]).IsAssignableFrom(type)
                && !typeof(Uri).IsAssignableFrom(type))
            {
                Type concrete = type.GetConcreteTypeIfNullable();

                if (concrete != type)
                {
                    result = IsPrimitiveOrEnum(concrete);
                }
                else
                {
                    result = false;
                }
            }

            return result;
        }