示例#1
0
        /// <summary>
        /// Safely returns the <see cref="Layout{T}"/> from a layout object.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="getter"></param>
        /// <typeparam name="TLayout"></typeparam>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public static LayoutList <T> Select <TLayout, T>(this Layout <TLayout> source, Func <TLayout, LayoutList <T> > getter)
            where TLayout : Layout
            where T : Layout
        {
            if (source == null || !source.IsPresent)
            {
                return(LayoutList.Missing <T>());
            }

            return(getter(source.Value) ?? LayoutList.Missing <T>());
        }
示例#2
0
        /// <summary>
        /// Safely returns the <see cref="LayoutList{TValue}"/> from the parsed result.
        /// </summary>
        /// <param name="result"></param>
        /// <param name="getter"></param>
        /// <typeparam name="TCursor"></typeparam>
        /// <typeparam name="TLayout"></typeparam>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public static LayoutList <T> Select <TCursor, TLayout, T>(this Result <Cursor <TCursor>, TLayout> result, Func <TLayout, LayoutList <T> > getter)
            where TLayout : Layout
            where T : Layout
        {
            if (result == null || !result.HasResult)
            {
                return(LayoutList.Missing <T>());
            }

            return(getter(result.Result) ?? LayoutList.Missing <T>());
        }
示例#3
0
        /// <summary>
        /// Safely returns the <see cref="Layout{T}"/> from a layout object.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="getter"></param>
        /// <typeparam name="TLayout"></typeparam>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public static LayoutList <T> Select <TLayout, T>(this Layout <TLayout> source, Func <TLayout, LayoutList <T> > getter)
            where TLayout : Layout
            where T : Layout
        {
            Debug.Assert(source != null);

            if (source == null || !source.HasValue)
            {
                return(LayoutList.Missing <T>());
            }

            return(getter(source.Value) ?? LayoutList.Missing <T>());
        }