Exemplo n.º 1
0
        private bool IsPrimitiveType(Type type)
        {
            if (type == null)
            {
                return(false);
            }

            if (type.IsNullable())
            {
                type = Nullable.GetUnderlyingType(type);
            }

            return(type.IsPrimitive || type == typeof(string) || type.IsEnum || PrimitiveTypes.Any(x => x.IsAssignableFrom(type)));
        }
Exemplo n.º 2
0
 /// <summary>
 /// Checks if the given type symbol represents a primitive type.
 /// </summary>
 /// <param name="type">The type symbol to check.</param>
 /// <returns><code>True</code> if the given type symbol is a primitive type.</returns>
 public static bool IsPrimitiveType(this ITypeSymbol type)
 {
     return(PrimitiveTypes.Any(primitiveType => primitiveType.IsType(type)));
 }