Esempio n. 1
0
 private static bool IsImplicitNullableConversion(Type sourceType, Type destinationType)
 {
     if (TypeHelper.IsNullableType(destinationType))
     {
         destinationType = destinationType.GetGenericArguments()[0];
         if (TypeHelper.IsNullableType(sourceType))
         {
             sourceType = sourceType.GetGenericArguments()[0];
         }
         return(TypeHelper.AreTypesCompatible(sourceType, destinationType));
     }
     else
     {
         return(false);
     }
 }
Esempio n. 2
0
 public static bool AreTypesCompatible(object source, Type destinationType)
 {
     if (source != null)
     {
         return(TypeHelper.AreTypesCompatible(source.GetType(), destinationType));
     }
     else
     {
         if (!destinationType.IsValueType)
         {
             return(true);
         }
         else
         {
             return(TypeHelper.IsNullableType(destinationType));
         }
     }
 }
Esempio n. 3
0
        public static bool ContainsCompatibleType(IEnumerable <Type> enumerable, Type targetType)
        {
            bool flag;
            IEnumerator <Type> enumerator = enumerable.GetEnumerator();

            using (enumerator)
            {
                while (enumerator.MoveNext())
                {
                    Type current = enumerator.Current;
                    if (!TypeHelper.AreTypesCompatible(current, targetType))
                    {
                        continue;
                    }
                    flag = true;
                    return(flag);
                }
                return(false);
            }
            return(flag);
        }