Beispiel #1
0
        /// <summary>
        /// True if the scorable is non-null, false otherwise.
        /// </summary>
        public static bool Keep <Item, Score>(IScorable <Item, Score> scorable)
        {
            // complicated because IScorable<Item, Score> is variant on generic parameter,
            // so generic type arguments of NullScorable<,> may not match generic type
            // arguments of IScorable<,>
            var type = scorable.GetType();

            if (type.IsGenericType)
            {
                var definition = type.GetGenericTypeDefinition();
                if (typeof(NullScorable <,>).IsAssignableFrom(definition))
                {
                    return(false);
                }
            }

            return(true);
        }