Beispiel #1
0
    public static bool DuckIs(this object instance, Type targetType)
    {
        if (instance is null)
        {
            DuckTypeTargetObjectInstanceIsNull.Throw();
        }

        if (targetType != null && (targetType.IsPublic || targetType.IsNestedPublic))
        {
            return(DuckType.CanCreate(targetType, instance));
        }

        return(false);
    }
Beispiel #2
0
    public static bool DuckIs <T>(this object instance)
    {
        if (instance is null)
        {
            DuckTypeTargetObjectInstanceIsNull.Throw();
        }

        if (DuckType.CreateCache <T> .IsVisible)
        {
            return(DuckType.CanCreate <T>(instance));
        }

        return(false);
    }