Exemplo n.º 1
0
        private static bool IsEnumExplicitlyCastable(Type from, Type to)
        {
            var innerFrom = from.IsEnum ? Enum.GetUnderlyingType(from) : from;
            var innerTo   = to.IsEnum ? Enum.GetUnderlyingType(to) : to;

            if (innerFrom == innerTo)
            {
                return(true);
            }

            return(BasicNetTypes.IsCastable(innerFrom, innerTo));
        }
Exemplo n.º 2
0
        public static bool IsExplicitlyCastable(Type from, Type to)
        {
            if (from.IsEnum || to.IsEnum)
            {
                return(BasicNetTypes.IsEnumExplicitlyCastable(from, to));
            }

            if (BasicNetTypes.aExplicitTypeConversions.TryGetValue(from, out var ret))
            {
                return(ret.Contains(to));
            }

            return(false);
        }
Exemplo n.º 3
0
 public static bool IsCastable <TFrom, TTo>()
 => BasicNetTypes.IsCastable(typeof(TFrom), typeof(TTo));
Exemplo n.º 4
0
 public static bool IsCastable(Type from, Type to)
 {
     return(BasicNetTypes.IsImplicitlyCastable(from, to) || BasicNetTypes.IsExplicitlyCastable(from, to));
 }
Exemplo n.º 5
0
 public static bool IsPrimitiveOrPrimitiveLikeType(Type type)
 => BasicNetTypes.IsPrimitiveType(type) || BasicNetTypes.IsPrimitiveLikeType(type);