Skip to content

Instantly share code, notes, and snippets.

@fearthecowboy
Last active August 29, 2015 13:56
Show Gist options
  • Save fearthecowboy/9312748 to your computer and use it in GitHub Desktop.
Save fearthecowboy/9312748 to your computer and use it in GitHub Desktop.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
namespace fooooooooo.Core.Extensions {
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public static class ArgumentExtensions {
public static bool CheckParameterType<T>(object obj, int index) {
// todo: we should probable see if we can coerce the type if it's not the expected type.
if (obj == null) {
if (typeof (T).IsPrimitive) {
throw new Exception("Invalid Argument #{0}to delegate. Expected non-nullable type'{1}' and found type '{2}'".format(index,typeof(T).Name, obj.GetType().Name));
}
return false;
}
if (obj is T) {
return true;
}
throw new Exception("Invalid Argument #{0}to delegate. Expected type'{1}' and found type '{2}'".format(index,typeof(T).Name, obj.GetType().Name));
}
public static object[] Verify<T0>( this IEnumerable<object> arguments ) {
if (arguments == null) {
return null;
}
var args = arguments.ToArray();
if (args.Length < 1) {
throw new Exception("Invalid number of arguments. Expected 1, found {0}".format(args.Length));
}
CheckParameterType<T0>(args[0], 0);
// nothing threw, types must be ok.
return args;
}
public static object[] Verify<T0 ,T1>( this IEnumerable<object> arguments ) {
if (arguments == null) {
return null;
}
var args = arguments.ToArray();
if (args.Length < 2) {
throw new Exception("Invalid number of arguments. Expected 2, found {0}".format(args.Length));
}
CheckParameterType<T0>(args[0], 0);
CheckParameterType<T1>(args[1], 1);
// nothing threw, types must be ok.
return args;
}
public static object[] Verify<T0 ,T1 ,T2>( this IEnumerable<object> arguments ) {
if (arguments == null) {
return null;
}
var args = arguments.ToArray();
if (args.Length < 3) {
throw new Exception("Invalid number of arguments. Expected 3, found {0}".format(args.Length));
}
CheckParameterType<T0>(args[0], 0);
CheckParameterType<T1>(args[1], 1);
CheckParameterType<T2>(args[2], 2);
// nothing threw, types must be ok.
return args;
}
public static object[] Verify<T0 ,T1 ,T2 ,T3>( this IEnumerable<object> arguments ) {
if (arguments == null) {
return null;
}
var args = arguments.ToArray();
if (args.Length < 4) {
throw new Exception("Invalid number of arguments. Expected 4, found {0}".format(args.Length));
}
CheckParameterType<T0>(args[0], 0);
CheckParameterType<T1>(args[1], 1);
CheckParameterType<T2>(args[2], 2);
CheckParameterType<T3>(args[3], 3);
// nothing threw, types must be ok.
return args;
}
public static object[] Verify<T0 ,T1 ,T2 ,T3 ,T4>( this IEnumerable<object> arguments ) {
if (arguments == null) {
return null;
}
var args = arguments.ToArray();
if (args.Length < 5) {
throw new Exception("Invalid number of arguments. Expected 5, found {0}".format(args.Length));
}
CheckParameterType<T0>(args[0], 0);
CheckParameterType<T1>(args[1], 1);
CheckParameterType<T2>(args[2], 2);
CheckParameterType<T3>(args[3], 3);
CheckParameterType<T4>(args[4], 4);
// nothing threw, types must be ok.
return args;
}
public static object[] Verify<T0 ,T1 ,T2 ,T3 ,T4 ,T5>( this IEnumerable<object> arguments ) {
if (arguments == null) {
return null;
}
var args = arguments.ToArray();
if (args.Length < 6) {
throw new Exception("Invalid number of arguments. Expected 6, found {0}".format(args.Length));
}
CheckParameterType<T0>(args[0], 0);
CheckParameterType<T1>(args[1], 1);
CheckParameterType<T2>(args[2], 2);
CheckParameterType<T3>(args[3], 3);
CheckParameterType<T4>(args[4], 4);
CheckParameterType<T5>(args[5], 5);
// nothing threw, types must be ok.
return args;
}
public static object[] Verify<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6>( this IEnumerable<object> arguments ) {
if (arguments == null) {
return null;
}
var args = arguments.ToArray();
if (args.Length < 7) {
throw new Exception("Invalid number of arguments. Expected 7, found {0}".format(args.Length));
}
CheckParameterType<T0>(args[0], 0);
CheckParameterType<T1>(args[1], 1);
CheckParameterType<T2>(args[2], 2);
CheckParameterType<T3>(args[3], 3);
CheckParameterType<T4>(args[4], 4);
CheckParameterType<T5>(args[5], 5);
CheckParameterType<T6>(args[6], 6);
// nothing threw, types must be ok.
return args;
}
public static object[] Verify<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6 ,T7>( this IEnumerable<object> arguments ) {
if (arguments == null) {
return null;
}
var args = arguments.ToArray();
if (args.Length < 8) {
throw new Exception("Invalid number of arguments. Expected 8, found {0}".format(args.Length));
}
CheckParameterType<T0>(args[0], 0);
CheckParameterType<T1>(args[1], 1);
CheckParameterType<T2>(args[2], 2);
CheckParameterType<T3>(args[3], 3);
CheckParameterType<T4>(args[4], 4);
CheckParameterType<T5>(args[5], 5);
CheckParameterType<T6>(args[6], 6);
CheckParameterType<T7>(args[7], 7);
// nothing threw, types must be ok.
return args;
}
public static object[] Verify<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6 ,T7 ,T8>( this IEnumerable<object> arguments ) {
if (arguments == null) {
return null;
}
var args = arguments.ToArray();
if (args.Length < 9) {
throw new Exception("Invalid number of arguments. Expected 9, found {0}".format(args.Length));
}
CheckParameterType<T0>(args[0], 0);
CheckParameterType<T1>(args[1], 1);
CheckParameterType<T2>(args[2], 2);
CheckParameterType<T3>(args[3], 3);
CheckParameterType<T4>(args[4], 4);
CheckParameterType<T5>(args[5], 5);
CheckParameterType<T6>(args[6], 6);
CheckParameterType<T7>(args[7], 7);
CheckParameterType<T8>(args[8], 8);
// nothing threw, types must be ok.
return args;
}
public static object[] Verify<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6 ,T7 ,T8 ,T9>( this IEnumerable<object> arguments ) {
if (arguments == null) {
return null;
}
var args = arguments.ToArray();
if (args.Length < 10) {
throw new Exception("Invalid number of arguments. Expected 10, found {0}".format(args.Length));
}
CheckParameterType<T0>(args[0], 0);
CheckParameterType<T1>(args[1], 1);
CheckParameterType<T2>(args[2], 2);
CheckParameterType<T3>(args[3], 3);
CheckParameterType<T4>(args[4], 4);
CheckParameterType<T5>(args[5], 5);
CheckParameterType<T6>(args[6], 6);
CheckParameterType<T7>(args[7], 7);
CheckParameterType<T8>(args[8], 8);
CheckParameterType<T9>(args[9], 9);
// nothing threw, types must be ok.
return args;
}
public static object[] Verify<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6 ,T7 ,T8 ,T9 ,T10>( this IEnumerable<object> arguments ) {
if (arguments == null) {
return null;
}
var args = arguments.ToArray();
if (args.Length < 11) {
throw new Exception("Invalid number of arguments. Expected 11, found {0}".format(args.Length));
}
CheckParameterType<T0>(args[0], 0);
CheckParameterType<T1>(args[1], 1);
CheckParameterType<T2>(args[2], 2);
CheckParameterType<T3>(args[3], 3);
CheckParameterType<T4>(args[4], 4);
CheckParameterType<T5>(args[5], 5);
CheckParameterType<T6>(args[6], 6);
CheckParameterType<T7>(args[7], 7);
CheckParameterType<T8>(args[8], 8);
CheckParameterType<T9>(args[9], 9);
CheckParameterType<T10>(args[10], 10);
// nothing threw, types must be ok.
return args;
}
public static object[] Verify<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6 ,T7 ,T8 ,T9 ,T10 ,T11>( this IEnumerable<object> arguments ) {
if (arguments == null) {
return null;
}
var args = arguments.ToArray();
if (args.Length < 12) {
throw new Exception("Invalid number of arguments. Expected 12, found {0}".format(args.Length));
}
CheckParameterType<T0>(args[0], 0);
CheckParameterType<T1>(args[1], 1);
CheckParameterType<T2>(args[2], 2);
CheckParameterType<T3>(args[3], 3);
CheckParameterType<T4>(args[4], 4);
CheckParameterType<T5>(args[5], 5);
CheckParameterType<T6>(args[6], 6);
CheckParameterType<T7>(args[7], 7);
CheckParameterType<T8>(args[8], 8);
CheckParameterType<T9>(args[9], 9);
CheckParameterType<T10>(args[10], 10);
CheckParameterType<T11>(args[11], 11);
// nothing threw, types must be ok.
return args;
}
public static object[] Verify<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6 ,T7 ,T8 ,T9 ,T10 ,T11 ,T12>( this IEnumerable<object> arguments ) {
if (arguments == null) {
return null;
}
var args = arguments.ToArray();
if (args.Length < 13) {
throw new Exception("Invalid number of arguments. Expected 13, found {0}".format(args.Length));
}
CheckParameterType<T0>(args[0], 0);
CheckParameterType<T1>(args[1], 1);
CheckParameterType<T2>(args[2], 2);
CheckParameterType<T3>(args[3], 3);
CheckParameterType<T4>(args[4], 4);
CheckParameterType<T5>(args[5], 5);
CheckParameterType<T6>(args[6], 6);
CheckParameterType<T7>(args[7], 7);
CheckParameterType<T8>(args[8], 8);
CheckParameterType<T9>(args[9], 9);
CheckParameterType<T10>(args[10], 10);
CheckParameterType<T11>(args[11], 11);
CheckParameterType<T12>(args[12], 12);
// nothing threw, types must be ok.
return args;
}
public static object[] Verify<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6 ,T7 ,T8 ,T9 ,T10 ,T11 ,T12 ,T13>( this IEnumerable<object> arguments ) {
if (arguments == null) {
return null;
}
var args = arguments.ToArray();
if (args.Length < 14) {
throw new Exception("Invalid number of arguments. Expected 14, found {0}".format(args.Length));
}
CheckParameterType<T0>(args[0], 0);
CheckParameterType<T1>(args[1], 1);
CheckParameterType<T2>(args[2], 2);
CheckParameterType<T3>(args[3], 3);
CheckParameterType<T4>(args[4], 4);
CheckParameterType<T5>(args[5], 5);
CheckParameterType<T6>(args[6], 6);
CheckParameterType<T7>(args[7], 7);
CheckParameterType<T8>(args[8], 8);
CheckParameterType<T9>(args[9], 9);
CheckParameterType<T10>(args[10], 10);
CheckParameterType<T11>(args[11], 11);
CheckParameterType<T12>(args[12], 12);
CheckParameterType<T13>(args[13], 13);
// nothing threw, types must be ok.
return args;
}
public static object[] Verify<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6 ,T7 ,T8 ,T9 ,T10 ,T11 ,T12 ,T13 ,T14>( this IEnumerable<object> arguments ) {
if (arguments == null) {
return null;
}
var args = arguments.ToArray();
if (args.Length < 15) {
throw new Exception("Invalid number of arguments. Expected 15, found {0}".format(args.Length));
}
CheckParameterType<T0>(args[0], 0);
CheckParameterType<T1>(args[1], 1);
CheckParameterType<T2>(args[2], 2);
CheckParameterType<T3>(args[3], 3);
CheckParameterType<T4>(args[4], 4);
CheckParameterType<T5>(args[5], 5);
CheckParameterType<T6>(args[6], 6);
CheckParameterType<T7>(args[7], 7);
CheckParameterType<T8>(args[8], 8);
CheckParameterType<T9>(args[9], 9);
CheckParameterType<T10>(args[10], 10);
CheckParameterType<T11>(args[11], 11);
CheckParameterType<T12>(args[12], 12);
CheckParameterType<T13>(args[13], 13);
CheckParameterType<T14>(args[14], 14);
// nothing threw, types must be ok.
return args;
}
public static object[] Verify<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6 ,T7 ,T8 ,T9 ,T10 ,T11 ,T12 ,T13 ,T14 ,T15>( this IEnumerable<object> arguments ) {
if (arguments == null) {
return null;
}
var args = arguments.ToArray();
if (args.Length < 16) {
throw new Exception("Invalid number of arguments. Expected 16, found {0}".format(args.Length));
}
CheckParameterType<T0>(args[0], 0);
CheckParameterType<T1>(args[1], 1);
CheckParameterType<T2>(args[2], 2);
CheckParameterType<T3>(args[3], 3);
CheckParameterType<T4>(args[4], 4);
CheckParameterType<T5>(args[5], 5);
CheckParameterType<T6>(args[6], 6);
CheckParameterType<T7>(args[7], 7);
CheckParameterType<T8>(args[8], 8);
CheckParameterType<T9>(args[9], 9);
CheckParameterType<T10>(args[10], 10);
CheckParameterType<T11>(args[11], 11);
CheckParameterType<T12>(args[12], 12);
CheckParameterType<T13>(args[13], 13);
CheckParameterType<T14>(args[14], 14);
CheckParameterType<T15>(args[15], 15);
// nothing threw, types must be ok.
return args;
}
public static object VerifyAndCall<T0>( this IEnumerable<object> arguments, Delegate d, Func<T0, object> funcToCall ) {
if (arguments == null) {
return d;
}
var args = arguments.ToArray();
if (args.Length < 1) {
throw new Exception("Invalid number of arguments. Expected 1, found {0}".format(args.Length));
}
CheckParameterType<T0>(args[0], 0);
// nothing threw, types must be ok.
return funcToCall( (T0)args[0]);
}
public static object VerifyAndCall<T0>( this IEnumerable<object> arguments, Delegate d, Action<T0> actionToCall ) {
if (arguments == null) {
return d;
}
var args = arguments.ToArray();
if (args.Length < 1) {
throw new Exception("Invalid number of arguments. Expected 1, found {0}".format(args.Length));
}
CheckParameterType<T0>(args[0], 0);
// nothing threw, types must be ok.
actionToCall( (T0)args[0]);
return null;
}
public static object VerifyAndCall<T0 ,T1>( this IEnumerable<object> arguments, Delegate d, Func<T0 ,T1, object> funcToCall ) {
if (arguments == null) {
return d;
}
var args = arguments.ToArray();
if (args.Length < 2) {
throw new Exception("Invalid number of arguments. Expected 2, found {0}".format(args.Length));
}
CheckParameterType<T0>(args[0], 0);
CheckParameterType<T1>(args[1], 1);
// nothing threw, types must be ok.
return funcToCall( (T0)args[0] , (T1)args[1]);
}
public static object VerifyAndCall<T0 ,T1>( this IEnumerable<object> arguments, Delegate d, Action<T0 ,T1> actionToCall ) {
if (arguments == null) {
return d;
}
var args = arguments.ToArray();
if (args.Length < 2) {
throw new Exception("Invalid number of arguments. Expected 2, found {0}".format(args.Length));
}
CheckParameterType<T0>(args[0], 0);
CheckParameterType<T1>(args[1], 1);
// nothing threw, types must be ok.
actionToCall( (T0)args[0] , (T1)args[1]);
return null;
}
public static object VerifyAndCall<T0 ,T1 ,T2>( this IEnumerable<object> arguments, Delegate d, Func<T0 ,T1 ,T2, object> funcToCall ) {
if (arguments == null) {
return d;
}
var args = arguments.ToArray();
if (args.Length < 3) {
throw new Exception("Invalid number of arguments. Expected 3, found {0}".format(args.Length));
}
CheckParameterType<T0>(args[0], 0);
CheckParameterType<T1>(args[1], 1);
CheckParameterType<T2>(args[2], 2);
// nothing threw, types must be ok.
return funcToCall( (T0)args[0] , (T1)args[1] , (T2)args[2]);
}
public static object VerifyAndCall<T0 ,T1 ,T2>( this IEnumerable<object> arguments, Delegate d, Action<T0 ,T1 ,T2> actionToCall ) {
if (arguments == null) {
return d;
}
var args = arguments.ToArray();
if (args.Length < 3) {
throw new Exception("Invalid number of arguments. Expected 3, found {0}".format(args.Length));
}
CheckParameterType<T0>(args[0], 0);
CheckParameterType<T1>(args[1], 1);
CheckParameterType<T2>(args[2], 2);
// nothing threw, types must be ok.
actionToCall( (T0)args[0] , (T1)args[1] , (T2)args[2]);
return null;
}
public static object VerifyAndCall<T0 ,T1 ,T2 ,T3>( this IEnumerable<object> arguments, Delegate d, Func<T0 ,T1 ,T2 ,T3, object> funcToCall ) {
if (arguments == null) {
return d;
}
var args = arguments.ToArray();
if (args.Length < 4) {
throw new Exception("Invalid number of arguments. Expected 4, found {0}".format(args.Length));
}
CheckParameterType<T0>(args[0], 0);
CheckParameterType<T1>(args[1], 1);
CheckParameterType<T2>(args[2], 2);
CheckParameterType<T3>(args[3], 3);
// nothing threw, types must be ok.
return funcToCall( (T0)args[0] , (T1)args[1] , (T2)args[2] , (T3)args[3]);
}
public static object VerifyAndCall<T0 ,T1 ,T2 ,T3>( this IEnumerable<object> arguments, Delegate d, Action<T0 ,T1 ,T2 ,T3> actionToCall ) {
if (arguments == null) {
return d;
}
var args = arguments.ToArray();
if (args.Length < 4) {
throw new Exception("Invalid number of arguments. Expected 4, found {0}".format(args.Length));
}
CheckParameterType<T0>(args[0], 0);
CheckParameterType<T1>(args[1], 1);
CheckParameterType<T2>(args[2], 2);
CheckParameterType<T3>(args[3], 3);
// nothing threw, types must be ok.
actionToCall( (T0)args[0] , (T1)args[1] , (T2)args[2] , (T3)args[3]);
return null;
}
public static object VerifyAndCall<T0 ,T1 ,T2 ,T3 ,T4>( this IEnumerable<object> arguments, Delegate d, Func<T0 ,T1 ,T2 ,T3 ,T4, object> funcToCall ) {
if (arguments == null) {
return d;
}
var args = arguments.ToArray();
if (args.Length < 5) {
throw new Exception("Invalid number of arguments. Expected 5, found {0}".format(args.Length));
}
CheckParameterType<T0>(args[0], 0);
CheckParameterType<T1>(args[1], 1);
CheckParameterType<T2>(args[2], 2);
CheckParameterType<T3>(args[3], 3);
CheckParameterType<T4>(args[4], 4);
// nothing threw, types must be ok.
return funcToCall( (T0)args[0] , (T1)args[1] , (T2)args[2] , (T3)args[3] , (T4)args[4]);
}
public static object VerifyAndCall<T0 ,T1 ,T2 ,T3 ,T4>( this IEnumerable<object> arguments, Delegate d, Action<T0 ,T1 ,T2 ,T3 ,T4> actionToCall ) {
if (arguments == null) {
return d;
}
var args = arguments.ToArray();
if (args.Length < 5) {
throw new Exception("Invalid number of arguments. Expected 5, found {0}".format(args.Length));
}
CheckParameterType<T0>(args[0], 0);
CheckParameterType<T1>(args[1], 1);
CheckParameterType<T2>(args[2], 2);
CheckParameterType<T3>(args[3], 3);
CheckParameterType<T4>(args[4], 4);
// nothing threw, types must be ok.
actionToCall( (T0)args[0] , (T1)args[1] , (T2)args[2] , (T3)args[3] , (T4)args[4]);
return null;
}
public static object VerifyAndCall<T0 ,T1 ,T2 ,T3 ,T4 ,T5>( this IEnumerable<object> arguments, Delegate d, Func<T0 ,T1 ,T2 ,T3 ,T4 ,T5, object> funcToCall ) {
if (arguments == null) {
return d;
}
var args = arguments.ToArray();
if (args.Length < 6) {
throw new Exception("Invalid number of arguments. Expected 6, found {0}".format(args.Length));
}
CheckParameterType<T0>(args[0], 0);
CheckParameterType<T1>(args[1], 1);
CheckParameterType<T2>(args[2], 2);
CheckParameterType<T3>(args[3], 3);
CheckParameterType<T4>(args[4], 4);
CheckParameterType<T5>(args[5], 5);
// nothing threw, types must be ok.
return funcToCall( (T0)args[0] , (T1)args[1] , (T2)args[2] , (T3)args[3] , (T4)args[4] , (T5)args[5]);
}
public static object VerifyAndCall<T0 ,T1 ,T2 ,T3 ,T4 ,T5>( this IEnumerable<object> arguments, Delegate d, Action<T0 ,T1 ,T2 ,T3 ,T4 ,T5> actionToCall ) {
if (arguments == null) {
return d;
}
var args = arguments.ToArray();
if (args.Length < 6) {
throw new Exception("Invalid number of arguments. Expected 6, found {0}".format(args.Length));
}
CheckParameterType<T0>(args[0], 0);
CheckParameterType<T1>(args[1], 1);
CheckParameterType<T2>(args[2], 2);
CheckParameterType<T3>(args[3], 3);
CheckParameterType<T4>(args[4], 4);
CheckParameterType<T5>(args[5], 5);
// nothing threw, types must be ok.
actionToCall( (T0)args[0] , (T1)args[1] , (T2)args[2] , (T3)args[3] , (T4)args[4] , (T5)args[5]);
return null;
}
public static object VerifyAndCall<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6>( this IEnumerable<object> arguments, Delegate d, Func<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6, object> funcToCall ) {
if (arguments == null) {
return d;
}
var args = arguments.ToArray();
if (args.Length < 7) {
throw new Exception("Invalid number of arguments. Expected 7, found {0}".format(args.Length));
}
CheckParameterType<T0>(args[0], 0);
CheckParameterType<T1>(args[1], 1);
CheckParameterType<T2>(args[2], 2);
CheckParameterType<T3>(args[3], 3);
CheckParameterType<T4>(args[4], 4);
CheckParameterType<T5>(args[5], 5);
CheckParameterType<T6>(args[6], 6);
// nothing threw, types must be ok.
return funcToCall( (T0)args[0] , (T1)args[1] , (T2)args[2] , (T3)args[3] , (T4)args[4] , (T5)args[5] , (T6)args[6]);
}
public static object VerifyAndCall<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6>( this IEnumerable<object> arguments, Delegate d, Action<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6> actionToCall ) {
if (arguments == null) {
return d;
}
var args = arguments.ToArray();
if (args.Length < 7) {
throw new Exception("Invalid number of arguments. Expected 7, found {0}".format(args.Length));
}
CheckParameterType<T0>(args[0], 0);
CheckParameterType<T1>(args[1], 1);
CheckParameterType<T2>(args[2], 2);
CheckParameterType<T3>(args[3], 3);
CheckParameterType<T4>(args[4], 4);
CheckParameterType<T5>(args[5], 5);
CheckParameterType<T6>(args[6], 6);
// nothing threw, types must be ok.
actionToCall( (T0)args[0] , (T1)args[1] , (T2)args[2] , (T3)args[3] , (T4)args[4] , (T5)args[5] , (T6)args[6]);
return null;
}
public static object VerifyAndCall<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6 ,T7>( this IEnumerable<object> arguments, Delegate d, Func<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6 ,T7, object> funcToCall ) {
if (arguments == null) {
return d;
}
var args = arguments.ToArray();
if (args.Length < 8) {
throw new Exception("Invalid number of arguments. Expected 8, found {0}".format(args.Length));
}
CheckParameterType<T0>(args[0], 0);
CheckParameterType<T1>(args[1], 1);
CheckParameterType<T2>(args[2], 2);
CheckParameterType<T3>(args[3], 3);
CheckParameterType<T4>(args[4], 4);
CheckParameterType<T5>(args[5], 5);
CheckParameterType<T6>(args[6], 6);
CheckParameterType<T7>(args[7], 7);
// nothing threw, types must be ok.
return funcToCall( (T0)args[0] , (T1)args[1] , (T2)args[2] , (T3)args[3] , (T4)args[4] , (T5)args[5] , (T6)args[6] , (T7)args[7]);
}
public static object VerifyAndCall<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6 ,T7>( this IEnumerable<object> arguments, Delegate d, Action<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6 ,T7> actionToCall ) {
if (arguments == null) {
return d;
}
var args = arguments.ToArray();
if (args.Length < 8) {
throw new Exception("Invalid number of arguments. Expected 8, found {0}".format(args.Length));
}
CheckParameterType<T0>(args[0], 0);
CheckParameterType<T1>(args[1], 1);
CheckParameterType<T2>(args[2], 2);
CheckParameterType<T3>(args[3], 3);
CheckParameterType<T4>(args[4], 4);
CheckParameterType<T5>(args[5], 5);
CheckParameterType<T6>(args[6], 6);
CheckParameterType<T7>(args[7], 7);
// nothing threw, types must be ok.
actionToCall( (T0)args[0] , (T1)args[1] , (T2)args[2] , (T3)args[3] , (T4)args[4] , (T5)args[5] , (T6)args[6] , (T7)args[7]);
return null;
}
public static object VerifyAndCall<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6 ,T7 ,T8>( this IEnumerable<object> arguments, Delegate d, Func<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6 ,T7 ,T8, object> funcToCall ) {
if (arguments == null) {
return d;
}
var args = arguments.ToArray();
if (args.Length < 9) {
throw new Exception("Invalid number of arguments. Expected 9, found {0}".format(args.Length));
}
CheckParameterType<T0>(args[0], 0);
CheckParameterType<T1>(args[1], 1);
CheckParameterType<T2>(args[2], 2);
CheckParameterType<T3>(args[3], 3);
CheckParameterType<T4>(args[4], 4);
CheckParameterType<T5>(args[5], 5);
CheckParameterType<T6>(args[6], 6);
CheckParameterType<T7>(args[7], 7);
CheckParameterType<T8>(args[8], 8);
// nothing threw, types must be ok.
return funcToCall( (T0)args[0] , (T1)args[1] , (T2)args[2] , (T3)args[3] , (T4)args[4] , (T5)args[5] , (T6)args[6] , (T7)args[7] , (T8)args[8]);
}
public static object VerifyAndCall<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6 ,T7 ,T8>( this IEnumerable<object> arguments, Delegate d, Action<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6 ,T7 ,T8> actionToCall ) {
if (arguments == null) {
return d;
}
var args = arguments.ToArray();
if (args.Length < 9) {
throw new Exception("Invalid number of arguments. Expected 9, found {0}".format(args.Length));
}
CheckParameterType<T0>(args[0], 0);
CheckParameterType<T1>(args[1], 1);
CheckParameterType<T2>(args[2], 2);
CheckParameterType<T3>(args[3], 3);
CheckParameterType<T4>(args[4], 4);
CheckParameterType<T5>(args[5], 5);
CheckParameterType<T6>(args[6], 6);
CheckParameterType<T7>(args[7], 7);
CheckParameterType<T8>(args[8], 8);
// nothing threw, types must be ok.
actionToCall( (T0)args[0] , (T1)args[1] , (T2)args[2] , (T3)args[3] , (T4)args[4] , (T5)args[5] , (T6)args[6] , (T7)args[7] , (T8)args[8]);
return null;
}
public static object VerifyAndCall<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6 ,T7 ,T8 ,T9>( this IEnumerable<object> arguments, Delegate d, Func<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6 ,T7 ,T8 ,T9, object> funcToCall ) {
if (arguments == null) {
return d;
}
var args = arguments.ToArray();
if (args.Length < 10) {
throw new Exception("Invalid number of arguments. Expected 10, found {0}".format(args.Length));
}
CheckParameterType<T0>(args[0], 0);
CheckParameterType<T1>(args[1], 1);
CheckParameterType<T2>(args[2], 2);
CheckParameterType<T3>(args[3], 3);
CheckParameterType<T4>(args[4], 4);
CheckParameterType<T5>(args[5], 5);
CheckParameterType<T6>(args[6], 6);
CheckParameterType<T7>(args[7], 7);
CheckParameterType<T8>(args[8], 8);
CheckParameterType<T9>(args[9], 9);
// nothing threw, types must be ok.
return funcToCall( (T0)args[0] , (T1)args[1] , (T2)args[2] , (T3)args[3] , (T4)args[4] , (T5)args[5] , (T6)args[6] , (T7)args[7] , (T8)args[8] , (T9)args[9]);
}
public static object VerifyAndCall<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6 ,T7 ,T8 ,T9>( this IEnumerable<object> arguments, Delegate d, Action<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6 ,T7 ,T8 ,T9> actionToCall ) {
if (arguments == null) {
return d;
}
var args = arguments.ToArray();
if (args.Length < 10) {
throw new Exception("Invalid number of arguments. Expected 10, found {0}".format(args.Length));
}
CheckParameterType<T0>(args[0], 0);
CheckParameterType<T1>(args[1], 1);
CheckParameterType<T2>(args[2], 2);
CheckParameterType<T3>(args[3], 3);
CheckParameterType<T4>(args[4], 4);
CheckParameterType<T5>(args[5], 5);
CheckParameterType<T6>(args[6], 6);
CheckParameterType<T7>(args[7], 7);
CheckParameterType<T8>(args[8], 8);
CheckParameterType<T9>(args[9], 9);
// nothing threw, types must be ok.
actionToCall( (T0)args[0] , (T1)args[1] , (T2)args[2] , (T3)args[3] , (T4)args[4] , (T5)args[5] , (T6)args[6] , (T7)args[7] , (T8)args[8] , (T9)args[9]);
return null;
}
public static object VerifyAndCall<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6 ,T7 ,T8 ,T9 ,T10>( this IEnumerable<object> arguments, Delegate d, Func<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6 ,T7 ,T8 ,T9 ,T10, object> funcToCall ) {
if (arguments == null) {
return d;
}
var args = arguments.ToArray();
if (args.Length < 11) {
throw new Exception("Invalid number of arguments. Expected 11, found {0}".format(args.Length));
}
CheckParameterType<T0>(args[0], 0);
CheckParameterType<T1>(args[1], 1);
CheckParameterType<T2>(args[2], 2);
CheckParameterType<T3>(args[3], 3);
CheckParameterType<T4>(args[4], 4);
CheckParameterType<T5>(args[5], 5);
CheckParameterType<T6>(args[6], 6);
CheckParameterType<T7>(args[7], 7);
CheckParameterType<T8>(args[8], 8);
CheckParameterType<T9>(args[9], 9);
CheckParameterType<T10>(args[10], 10);
// nothing threw, types must be ok.
return funcToCall( (T0)args[0] , (T1)args[1] , (T2)args[2] , (T3)args[3] , (T4)args[4] , (T5)args[5] , (T6)args[6] , (T7)args[7] , (T8)args[8] , (T9)args[9] , (T10)args[10]);
}
public static object VerifyAndCall<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6 ,T7 ,T8 ,T9 ,T10>( this IEnumerable<object> arguments, Delegate d, Action<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6 ,T7 ,T8 ,T9 ,T10> actionToCall ) {
if (arguments == null) {
return d;
}
var args = arguments.ToArray();
if (args.Length < 11) {
throw new Exception("Invalid number of arguments. Expected 11, found {0}".format(args.Length));
}
CheckParameterType<T0>(args[0], 0);
CheckParameterType<T1>(args[1], 1);
CheckParameterType<T2>(args[2], 2);
CheckParameterType<T3>(args[3], 3);
CheckParameterType<T4>(args[4], 4);
CheckParameterType<T5>(args[5], 5);
CheckParameterType<T6>(args[6], 6);
CheckParameterType<T7>(args[7], 7);
CheckParameterType<T8>(args[8], 8);
CheckParameterType<T9>(args[9], 9);
CheckParameterType<T10>(args[10], 10);
// nothing threw, types must be ok.
actionToCall( (T0)args[0] , (T1)args[1] , (T2)args[2] , (T3)args[3] , (T4)args[4] , (T5)args[5] , (T6)args[6] , (T7)args[7] , (T8)args[8] , (T9)args[9] , (T10)args[10]);
return null;
}
public static object VerifyAndCall<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6 ,T7 ,T8 ,T9 ,T10 ,T11>( this IEnumerable<object> arguments, Delegate d, Func<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6 ,T7 ,T8 ,T9 ,T10 ,T11, object> funcToCall ) {
if (arguments == null) {
return d;
}
var args = arguments.ToArray();
if (args.Length < 12) {
throw new Exception("Invalid number of arguments. Expected 12, found {0}".format(args.Length));
}
CheckParameterType<T0>(args[0], 0);
CheckParameterType<T1>(args[1], 1);
CheckParameterType<T2>(args[2], 2);
CheckParameterType<T3>(args[3], 3);
CheckParameterType<T4>(args[4], 4);
CheckParameterType<T5>(args[5], 5);
CheckParameterType<T6>(args[6], 6);
CheckParameterType<T7>(args[7], 7);
CheckParameterType<T8>(args[8], 8);
CheckParameterType<T9>(args[9], 9);
CheckParameterType<T10>(args[10], 10);
CheckParameterType<T11>(args[11], 11);
// nothing threw, types must be ok.
return funcToCall( (T0)args[0] , (T1)args[1] , (T2)args[2] , (T3)args[3] , (T4)args[4] , (T5)args[5] , (T6)args[6] , (T7)args[7] , (T8)args[8] , (T9)args[9] , (T10)args[10] , (T11)args[11]);
}
public static object VerifyAndCall<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6 ,T7 ,T8 ,T9 ,T10 ,T11>( this IEnumerable<object> arguments, Delegate d, Action<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6 ,T7 ,T8 ,T9 ,T10 ,T11> actionToCall ) {
if (arguments == null) {
return d;
}
var args = arguments.ToArray();
if (args.Length < 12) {
throw new Exception("Invalid number of arguments. Expected 12, found {0}".format(args.Length));
}
CheckParameterType<T0>(args[0], 0);
CheckParameterType<T1>(args[1], 1);
CheckParameterType<T2>(args[2], 2);
CheckParameterType<T3>(args[3], 3);
CheckParameterType<T4>(args[4], 4);
CheckParameterType<T5>(args[5], 5);
CheckParameterType<T6>(args[6], 6);
CheckParameterType<T7>(args[7], 7);
CheckParameterType<T8>(args[8], 8);
CheckParameterType<T9>(args[9], 9);
CheckParameterType<T10>(args[10], 10);
CheckParameterType<T11>(args[11], 11);
// nothing threw, types must be ok.
actionToCall( (T0)args[0] , (T1)args[1] , (T2)args[2] , (T3)args[3] , (T4)args[4] , (T5)args[5] , (T6)args[6] , (T7)args[7] , (T8)args[8] , (T9)args[9] , (T10)args[10] , (T11)args[11]);
return null;
}
public static object VerifyAndCall<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6 ,T7 ,T8 ,T9 ,T10 ,T11 ,T12>( this IEnumerable<object> arguments, Delegate d, Func<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6 ,T7 ,T8 ,T9 ,T10 ,T11 ,T12, object> funcToCall ) {
if (arguments == null) {
return d;
}
var args = arguments.ToArray();
if (args.Length < 13) {
throw new Exception("Invalid number of arguments. Expected 13, found {0}".format(args.Length));
}
CheckParameterType<T0>(args[0], 0);
CheckParameterType<T1>(args[1], 1);
CheckParameterType<T2>(args[2], 2);
CheckParameterType<T3>(args[3], 3);
CheckParameterType<T4>(args[4], 4);
CheckParameterType<T5>(args[5], 5);
CheckParameterType<T6>(args[6], 6);
CheckParameterType<T7>(args[7], 7);
CheckParameterType<T8>(args[8], 8);
CheckParameterType<T9>(args[9], 9);
CheckParameterType<T10>(args[10], 10);
CheckParameterType<T11>(args[11], 11);
CheckParameterType<T12>(args[12], 12);
// nothing threw, types must be ok.
return funcToCall( (T0)args[0] , (T1)args[1] , (T2)args[2] , (T3)args[3] , (T4)args[4] , (T5)args[5] , (T6)args[6] , (T7)args[7] , (T8)args[8] , (T9)args[9] , (T10)args[10] , (T11)args[11] , (T12)args[12]);
}
public static object VerifyAndCall<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6 ,T7 ,T8 ,T9 ,T10 ,T11 ,T12>( this IEnumerable<object> arguments, Delegate d, Action<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6 ,T7 ,T8 ,T9 ,T10 ,T11 ,T12> actionToCall ) {
if (arguments == null) {
return d;
}
var args = arguments.ToArray();
if (args.Length < 13) {
throw new Exception("Invalid number of arguments. Expected 13, found {0}".format(args.Length));
}
CheckParameterType<T0>(args[0], 0);
CheckParameterType<T1>(args[1], 1);
CheckParameterType<T2>(args[2], 2);
CheckParameterType<T3>(args[3], 3);
CheckParameterType<T4>(args[4], 4);
CheckParameterType<T5>(args[5], 5);
CheckParameterType<T6>(args[6], 6);
CheckParameterType<T7>(args[7], 7);
CheckParameterType<T8>(args[8], 8);
CheckParameterType<T9>(args[9], 9);
CheckParameterType<T10>(args[10], 10);
CheckParameterType<T11>(args[11], 11);
CheckParameterType<T12>(args[12], 12);
// nothing threw, types must be ok.
actionToCall( (T0)args[0] , (T1)args[1] , (T2)args[2] , (T3)args[3] , (T4)args[4] , (T5)args[5] , (T6)args[6] , (T7)args[7] , (T8)args[8] , (T9)args[9] , (T10)args[10] , (T11)args[11] , (T12)args[12]);
return null;
}
public static object VerifyAndCall<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6 ,T7 ,T8 ,T9 ,T10 ,T11 ,T12 ,T13>( this IEnumerable<object> arguments, Delegate d, Func<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6 ,T7 ,T8 ,T9 ,T10 ,T11 ,T12 ,T13, object> funcToCall ) {
if (arguments == null) {
return d;
}
var args = arguments.ToArray();
if (args.Length < 14) {
throw new Exception("Invalid number of arguments. Expected 14, found {0}".format(args.Length));
}
CheckParameterType<T0>(args[0], 0);
CheckParameterType<T1>(args[1], 1);
CheckParameterType<T2>(args[2], 2);
CheckParameterType<T3>(args[3], 3);
CheckParameterType<T4>(args[4], 4);
CheckParameterType<T5>(args[5], 5);
CheckParameterType<T6>(args[6], 6);
CheckParameterType<T7>(args[7], 7);
CheckParameterType<T8>(args[8], 8);
CheckParameterType<T9>(args[9], 9);
CheckParameterType<T10>(args[10], 10);
CheckParameterType<T11>(args[11], 11);
CheckParameterType<T12>(args[12], 12);
CheckParameterType<T13>(args[13], 13);
// nothing threw, types must be ok.
return funcToCall( (T0)args[0] , (T1)args[1] , (T2)args[2] , (T3)args[3] , (T4)args[4] , (T5)args[5] , (T6)args[6] , (T7)args[7] , (T8)args[8] , (T9)args[9] , (T10)args[10] , (T11)args[11] , (T12)args[12] , (T13)args[13]);
}
public static object VerifyAndCall<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6 ,T7 ,T8 ,T9 ,T10 ,T11 ,T12 ,T13>( this IEnumerable<object> arguments, Delegate d, Action<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6 ,T7 ,T8 ,T9 ,T10 ,T11 ,T12 ,T13> actionToCall ) {
if (arguments == null) {
return d;
}
var args = arguments.ToArray();
if (args.Length < 14) {
throw new Exception("Invalid number of arguments. Expected 14, found {0}".format(args.Length));
}
CheckParameterType<T0>(args[0], 0);
CheckParameterType<T1>(args[1], 1);
CheckParameterType<T2>(args[2], 2);
CheckParameterType<T3>(args[3], 3);
CheckParameterType<T4>(args[4], 4);
CheckParameterType<T5>(args[5], 5);
CheckParameterType<T6>(args[6], 6);
CheckParameterType<T7>(args[7], 7);
CheckParameterType<T8>(args[8], 8);
CheckParameterType<T9>(args[9], 9);
CheckParameterType<T10>(args[10], 10);
CheckParameterType<T11>(args[11], 11);
CheckParameterType<T12>(args[12], 12);
CheckParameterType<T13>(args[13], 13);
// nothing threw, types must be ok.
actionToCall( (T0)args[0] , (T1)args[1] , (T2)args[2] , (T3)args[3] , (T4)args[4] , (T5)args[5] , (T6)args[6] , (T7)args[7] , (T8)args[8] , (T9)args[9] , (T10)args[10] , (T11)args[11] , (T12)args[12] , (T13)args[13]);
return null;
}
public static object VerifyAndCall<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6 ,T7 ,T8 ,T9 ,T10 ,T11 ,T12 ,T13 ,T14>( this IEnumerable<object> arguments, Delegate d, Func<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6 ,T7 ,T8 ,T9 ,T10 ,T11 ,T12 ,T13 ,T14, object> funcToCall ) {
if (arguments == null) {
return d;
}
var args = arguments.ToArray();
if (args.Length < 15) {
throw new Exception("Invalid number of arguments. Expected 15, found {0}".format(args.Length));
}
CheckParameterType<T0>(args[0], 0);
CheckParameterType<T1>(args[1], 1);
CheckParameterType<T2>(args[2], 2);
CheckParameterType<T3>(args[3], 3);
CheckParameterType<T4>(args[4], 4);
CheckParameterType<T5>(args[5], 5);
CheckParameterType<T6>(args[6], 6);
CheckParameterType<T7>(args[7], 7);
CheckParameterType<T8>(args[8], 8);
CheckParameterType<T9>(args[9], 9);
CheckParameterType<T10>(args[10], 10);
CheckParameterType<T11>(args[11], 11);
CheckParameterType<T12>(args[12], 12);
CheckParameterType<T13>(args[13], 13);
CheckParameterType<T14>(args[14], 14);
// nothing threw, types must be ok.
return funcToCall( (T0)args[0] , (T1)args[1] , (T2)args[2] , (T3)args[3] , (T4)args[4] , (T5)args[5] , (T6)args[6] , (T7)args[7] , (T8)args[8] , (T9)args[9] , (T10)args[10] , (T11)args[11] , (T12)args[12] , (T13)args[13] , (T14)args[14]);
}
public static object VerifyAndCall<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6 ,T7 ,T8 ,T9 ,T10 ,T11 ,T12 ,T13 ,T14>( this IEnumerable<object> arguments, Delegate d, Action<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6 ,T7 ,T8 ,T9 ,T10 ,T11 ,T12 ,T13 ,T14> actionToCall ) {
if (arguments == null) {
return d;
}
var args = arguments.ToArray();
if (args.Length < 15) {
throw new Exception("Invalid number of arguments. Expected 15, found {0}".format(args.Length));
}
CheckParameterType<T0>(args[0], 0);
CheckParameterType<T1>(args[1], 1);
CheckParameterType<T2>(args[2], 2);
CheckParameterType<T3>(args[3], 3);
CheckParameterType<T4>(args[4], 4);
CheckParameterType<T5>(args[5], 5);
CheckParameterType<T6>(args[6], 6);
CheckParameterType<T7>(args[7], 7);
CheckParameterType<T8>(args[8], 8);
CheckParameterType<T9>(args[9], 9);
CheckParameterType<T10>(args[10], 10);
CheckParameterType<T11>(args[11], 11);
CheckParameterType<T12>(args[12], 12);
CheckParameterType<T13>(args[13], 13);
CheckParameterType<T14>(args[14], 14);
// nothing threw, types must be ok.
actionToCall( (T0)args[0] , (T1)args[1] , (T2)args[2] , (T3)args[3] , (T4)args[4] , (T5)args[5] , (T6)args[6] , (T7)args[7] , (T8)args[8] , (T9)args[9] , (T10)args[10] , (T11)args[11] , (T12)args[12] , (T13)args[13] , (T14)args[14]);
return null;
}
public static object VerifyAndCall<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6 ,T7 ,T8 ,T9 ,T10 ,T11 ,T12 ,T13 ,T14 ,T15>( this IEnumerable<object> arguments, Delegate d, Func<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6 ,T7 ,T8 ,T9 ,T10 ,T11 ,T12 ,T13 ,T14 ,T15, object> funcToCall ) {
if (arguments == null) {
return d;
}
var args = arguments.ToArray();
if (args.Length < 16) {
throw new Exception("Invalid number of arguments. Expected 16, found {0}".format(args.Length));
}
CheckParameterType<T0>(args[0], 0);
CheckParameterType<T1>(args[1], 1);
CheckParameterType<T2>(args[2], 2);
CheckParameterType<T3>(args[3], 3);
CheckParameterType<T4>(args[4], 4);
CheckParameterType<T5>(args[5], 5);
CheckParameterType<T6>(args[6], 6);
CheckParameterType<T7>(args[7], 7);
CheckParameterType<T8>(args[8], 8);
CheckParameterType<T9>(args[9], 9);
CheckParameterType<T10>(args[10], 10);
CheckParameterType<T11>(args[11], 11);
CheckParameterType<T12>(args[12], 12);
CheckParameterType<T13>(args[13], 13);
CheckParameterType<T14>(args[14], 14);
CheckParameterType<T15>(args[15], 15);
// nothing threw, types must be ok.
return funcToCall( (T0)args[0] , (T1)args[1] , (T2)args[2] , (T3)args[3] , (T4)args[4] , (T5)args[5] , (T6)args[6] , (T7)args[7] , (T8)args[8] , (T9)args[9] , (T10)args[10] , (T11)args[11] , (T12)args[12] , (T13)args[13] , (T14)args[14] , (T15)args[15]);
}
public static object VerifyAndCall<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6 ,T7 ,T8 ,T9 ,T10 ,T11 ,T12 ,T13 ,T14 ,T15>( this IEnumerable<object> arguments, Delegate d, Action<T0 ,T1 ,T2 ,T3 ,T4 ,T5 ,T6 ,T7 ,T8 ,T9 ,T10 ,T11 ,T12 ,T13 ,T14 ,T15> actionToCall ) {
if (arguments == null) {
return d;
}
var args = arguments.ToArray();
if (args.Length < 16) {
throw new Exception("Invalid number of arguments. Expected 16, found {0}".format(args.Length));
}
CheckParameterType<T0>(args[0], 0);
CheckParameterType<T1>(args[1], 1);
CheckParameterType<T2>(args[2], 2);
CheckParameterType<T3>(args[3], 3);
CheckParameterType<T4>(args[4], 4);
CheckParameterType<T5>(args[5], 5);
CheckParameterType<T6>(args[6], 6);
CheckParameterType<T7>(args[7], 7);
CheckParameterType<T8>(args[8], 8);
CheckParameterType<T9>(args[9], 9);
CheckParameterType<T10>(args[10], 10);
CheckParameterType<T11>(args[11], 11);
CheckParameterType<T12>(args[12], 12);
CheckParameterType<T13>(args[13], 13);
CheckParameterType<T14>(args[14], 14);
CheckParameterType<T15>(args[15], 15);
// nothing threw, types must be ok.
actionToCall( (T0)args[0] , (T1)args[1] , (T2)args[2] , (T3)args[3] , (T4)args[4] , (T5)args[5] , (T6)args[6] , (T7)args[7] , (T8)args[8] , (T9)args[9] , (T10)args[10] , (T11)args[11] , (T12)args[12] , (T13)args[13] , (T14)args[14] , (T15)args[15]);
return null;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment