Ejemplo n.º 1
0
        public static IEnumerable SelectNullable <T>(this NullAllowed <T> nullable,
                                                     Func <T, IEnumerable> selector)
            where T : class
        {
            Contract.Requires(selector != null);

            return(nullable.Select(selector).AllowNull());
        }
Ejemplo n.º 2
0
        public static ICollection <TResult> SelectNullable <T, TResult>(this NullAllowed <T> nullable,
                                                                        Func <T, ICollection <TResult> > selector)
            where T : class
        {
            Contract.Requires(selector != null);

            return(nullable.Select(selector).AllowNull());
        }
Ejemplo n.º 3
0
        public static TResult Select <T, TResult>(this NullAllowed <T> nullable, Func <T, TResult> selector)
            where T : class
        {
            Contract.Requires(selector != null);

            T target = nullable.Target;

            if (target == null)
            {
                return(default(TResult));
            }

            return(selector(target));
        }