Beispiel #1
0
        public static T MatchWith <T, T1, T2, T3, T4, T5>(this IMatchTypes <T1, T2, T3, T4, T5> self, Func <T1, T> a1, Func <T2, T> a2, Func <T3, T> a3, Func <T4, T> a4, Func <T5, T> a5)
            where T1 : class
            where T2 : class
            where T3 : class
            where T4 : class
            where T5 : class
        {
            var t1 = self as T1; if (t1 != null)
            {
                return(a1(t1));
            }
            var t2 = self as T2; if (t2 != null)
            {
                return(a2(t2));
            }
            var t3 = self as T3; if (t3 != null)
            {
                return(a3(t3));
            }
            var t4 = self as T4; if (t4 != null)
            {
                return(a4(t4));
            }
            var t5 = self as T5; if (t5 != null)

            {
                return(a5(t5));
            }

            throw new ArgumentException();
        }
Beispiel #2
0
 public static void Do <T1, T2, T3, T4, T5>(this IMatchTypes <T1, T2, T3, T4, T5> self, Action <T1> a1, Action <T2> a2, Action <T3> a3, Action <T4> a4, Action <T5> a5)
     where T1 : class
     where T2 : class
     where T3 : class
     where T4 : class
     where T5 : class
 {
     var t1 = self as T1; if (t1 != null)
     {
         a1(t1);
     }
     var t2 = self as T2; if (t2 != null)
     {
         a2(t2);
     }
     var t3 = self as T3; if (t3 != null)
     {
         a3(t3);
     }
     var t4 = self as T4; if (t4 != null)
     {
         a4(t4);
     }
     var t5 = self as T5; if (t5 != null)
     {
         a5(t5);
     }
 }
Beispiel #3
0
 public static void Do <T1>(this IMatchTypes <T1> self, Action <T1> a1)
     where T1 : class
 {
     var t1 = self as T1; if (t1 != null)
     {
         a1(t1);
     }
 }
Beispiel #4
0
        public static T MatchWith <T, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(
            this IMatchTypes <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> self,
            Func <T1, T> a1, Func <T2, T> a2, Func <T3, T> a3, Func <T4, T> a4, Func <T5, T> a5, Func <T6, T> a6, Func <T7, T> a7, Func <T8, T> a8, Func <T9, T> a9, Func <T10, T> a10)
            where T1 : class
            where T2 : class
            where T3 : class
            where T4 : class
            where T5 : class
            where T6 : class
            where T7 : class
            where T8 : class
            where T9 : class
            where T10 : class
        {
            var t1 = self as T1; if (t1 != null)
            {
                return(a1(t1));
            }
            var t2 = self as T2; if (t2 != null)
            {
                return(a2(t2));
            }
            var t3 = self as T3; if (t3 != null)
            {
                return(a3(t3));
            }
            var t4 = self as T4; if (t4 != null)
            {
                return(a4(t4));
            }
            var t5 = self as T5; if (t5 != null)
            {
                return(a5(t5));
            }
            var t6 = self as T6; if (t6 != null)
            {
                return(a6(t6));
            }
            var t7 = self as T7; if (t7 != null)
            {
                return(a7(t7));
            }
            var t8 = self as T8; if (t8 != null)
            {
                return(a8(t8));
            }
            var t9 = self as T9; if (t9 != null)
            {
                return(a9(t9));
            }
            var t10 = self as T10; if (t10 != null)

            {
                return(a10(t10));
            }

            throw new ArgumentException();
        }
Beispiel #5
0
        public static T MatchWith <T, T1>(this IMatchTypes <T1> self, Func <T1, T> a1)
            where T1 : class
        {
            var t1 = self as T1; if (t1 != null)

            {
                return(a1(t1));
            }

            throw new ArgumentException();
        }
Beispiel #6
0
 public static void Do <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(this IMatchTypes <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> self, Action <T1> a1, Action <T2> a2, Action <T3> a3, Action <T4> a4, Action <T5> a5, Action <T6> a6, Action <T7> a7, Action <T8> a8, Action <T9> a9, Action <T10> a10)
     where T1 : class
     where T2 : class
     where T3 : class
     where T4 : class
     where T5 : class
     where T6 : class
     where T7 : class
     where T8 : class
     where T9 : class
     where T10 : class
 {
     var t1 = self as T1; if (t1 != null)
     {
         a1(t1);
     }
     var t2 = self as T2; if (t2 != null)
     {
         a2(t2);
     }
     var t3 = self as T3; if (t3 != null)
     {
         a3(t3);
     }
     var t4 = self as T4; if (t4 != null)
     {
         a4(t4);
     }
     var t5 = self as T5; if (t5 != null)
     {
         a5(t5);
     }
     var t6 = self as T6; if (t6 != null)
     {
         a6(t6);
     }
     var t7 = self as T7; if (t7 != null)
     {
         a7(t7);
     }
     var t8 = self as T8; if (t8 != null)
     {
         a8(t8);
     }
     var t9 = self as T9; if (t9 != null)
     {
         a9(t9);
     }
     var t10 = self as T10; if (t10 != null)
     {
         a10(t10);
     }
 }
Beispiel #7
0
 public static void Do <T1, T2>(this IMatchTypes <T1, T2> self, Action <T1> a1, Action <T2> a2)
     where T1 : class
     where T2 : class
 {
     var t1 = self as T1; if (t1 != null)
     {
         a1(t1);
     }
     var t2 = self as T2; if (t2 != null)
     {
         a2(t2);
     }
 }
Beispiel #8
0
        public static T MatchWith <T, T1, T2>(this IMatchTypes <T1, T2> self, Func <T1, T> a1, Func <T2, T> a2)
            where T1 : class
            where T2 : class
        {
            var t1 = self as T1; if (t1 != null)
            {
                return(a1(t1));
            }
            var t2 = self as T2; if (t2 != null)

            {
                return(a2(t2));
            }

            throw new ArgumentException();
        }
Beispiel #9
0
 public static void Do <T1, T2, T3>(this IMatchTypes <T1, T2, T3> self, Action <T1> a1, Action <T2> a2, Action <T3> a3)
     where T1 : class
     where T2 : class
     where T3 : class
 {
     var t1 = self as T1; if (t1 != null)
     {
         a1(t1);
     }
     var t2 = self as T2; if (t2 != null)
     {
         a2(t2);
     }
     var t3 = self as T3; if (t3 != null)
     {
         a3(t3);
     }
 }
Beispiel #10
0
 public static void Do <T1, T2, T3, T4, T5, T6, T7>(this IMatchTypes <T1, T2, T3, T4, T5, T6, T7> self, Action <T1> a1, Action <T2> a2, Action <T3> a3, Action <T4> a4, Action <T5> a5, Action <T6> a6, Action <T7> a7)
     where T1 : class
     where T2 : class
     where T3 : class
     where T4 : class
     where T5 : class
     where T6 : class
     where T7 : class
 {
     var t1 = self as T1; if (t1 != null)
     {
         a1(t1);
     }
     var t2 = self as T2; if (t2 != null)
     {
         a2(t2);
     }
     var t3 = self as T3; if (t3 != null)
     {
         a3(t3);
     }
     var t4 = self as T4; if (t4 != null)
     {
         a4(t4);
     }
     var t5 = self as T5; if (t5 != null)
     {
         a5(t5);
     }
     var t6 = self as T6; if (t6 != null)
     {
         a6(t6);
     }
     var t7 = self as T7; if (t7 != null)
     {
         a7(t7);
     }
 }