Пример #1
0
 /// <summary>
 /// Defaults the specified switch.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <typeparam name="R"></typeparam>
 /// <param name="switch">The switch.</param>
 /// <param name="do">The do.</param>
 /// <returns></returns>
 public static R Default <T, R>(this Switch <T, R> @switch, Func <R> @do)
 {
     if ([email protected])
     {
         @switch.Set(@do());
     }
     return(@switch.Value);
 }
Пример #2
0
 /// <summary>
 /// Defaults the specified switch.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <typeparam name="R"></typeparam>
 /// <param name="switch">The switch.</param>
 /// <param name="result">The result.</param>
 /// <returns></returns>
 public static R Default <T, R>(this Switch <T, R> @switch, R result)
 {
     if ([email protected])
     {
         @switch.Set(result);
     }
     return(@switch.Value);
 }
Пример #3
0
        /// <summary>
        /// Cases the specified switch.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <typeparam name="R"></typeparam>
        /// <param name="switch">The switch.</param>
        /// <param name="case">The case.</param>
        /// <param name="do">The do.</param>
        /// <returns></returns>
        public static Switch <T, R> Case <T, R>(this Switch <T, R> @switch, Func <T, bool> @case, Func <T, R> @do)
        {
            if ([email protected] && @case(@switch.Object))
            {
                @switch.Set(@do(@switch.Object));
            }

            return(@switch);
        }