Example #1
0
 private static System.Type GetGenericCollectionTypeFromInterface(System.Type type)
 {
     System.Type genericTypeDefinition = PlatformTypeHelper.GetGenericTypeDefinition(type);
     if (genericTypeDefinition != null && typeof(ICollection <>).IsAssignableFrom(genericTypeDefinition))
     {
         System.Type[] genericTypeArguments = PlatformTypeHelper.GetGenericTypeArguments(type);
         if (genericTypeArguments != null)
         {
             return(genericTypeArguments[0]);
         }
     }
     return(null);
 }
Example #2
0
        public static Type GetNullableType(Type type)
        {
            Type genericTypeDefinition = PlatformTypeHelper.GetGenericTypeDefinition(type);

            if (genericTypeDefinition != (Type)null && typeof(Nullable <>).IsAssignableFrom(genericTypeDefinition))
            {
                Type[] genericTypeArguments = PlatformTypeHelper.GetGenericTypeArguments(type);
                if (genericTypeArguments != null && genericTypeArguments.Length == 1)
                {
                    return(genericTypeArguments[0]);
                }
            }
            return((Type)null);
        }