@@ -662,5 +662,42 @@ public static bool IsBrowsable([NotNull] this Type type) =>
662662 [ Pure ]
663663 public static bool IsBrowsable ( [ NotNull ] this MemberInfo member ) =>
664664 member . GetCustomAttribute < BrowsableAttribute > ( ) ? . Browsable ?? true ;
665+
666+ /// <summary>
667+ /// Determines whether instance of <typeparamref name="T"/> can be assigned to instance of current type.
668+ /// </summary>
669+ /// <typeparam name="T">Type to check</typeparam>
670+ /// <param name="type">Target type.</param>
671+ /// <returns>
672+ /// <c>true</c> if instance of <typeparamref name="T"/> can be assigned to instance of current type; otherwise, <c>false</c>.
673+ /// </returns>
674+ [ Pure ]
675+ public static bool IsAssignableFrom < T > ( [ NotNull ] this Type type ) => type . IsAssignableFrom ( typeof ( T ) ) ;
676+
677+ /// <summary>
678+ /// Determines whether instance of current type can be assigned to instance of <typeparamref name="T"/>.
679+ /// </summary>
680+ /// <typeparam name="T">Target type</typeparam>
681+ /// <param name="type">The type to check.</param>
682+ /// <returns>
683+ /// <c>true</c> if instance of current type can be assigned to instance of <typeparamref name="T"/>; otherwise, <c>false</c>.
684+ /// </returns>
685+ [ Pure ]
686+ public static bool IsAssignableTo < T > ( [ NotNull ] this Type type ) => typeof ( T ) . IsAssignableFrom ( type ) ;
687+
688+ /// <summary>
689+ /// Determines whether instance of current type can be assigned to instance of <paramref name="targetType"/>.
690+ /// </summary>
691+ /// <param name="type">The type to check.</param>
692+ /// <param name="targetType">Target type.</param>
693+ /// <returns>
694+ /// <c>true</c> if instance of current type can be assigned to instance of <paramref name="targetType"/>; otherwise, <c>false</c>.
695+ /// </returns>
696+ [ Pure ]
697+ public static bool IsAssignableTo ( [ NotNull ] this Type type , Type targetType )
698+ {
699+ Code . NotNull ( targetType , nameof ( targetType ) ) ;
700+ return targetType . IsAssignableFrom ( type ) ;
701+ }
665702 }
666703}
0 commit comments