public static void Deconstruct <T1, T2, T3>(this ITuple value, out T1 item1, out T2 item2, out T3 item3) { value.OfSize(3); item1 = value.Get <T1>(0); item2 = value.Get <T2>(1); item3 = value.Get <T3>(2); }
/// <summary>Returns a typed version of a tuple of size 2</summary> /// <typeparam name="T1">Expected type of the first element</typeparam> /// <typeparam name="T2">Expected type of the second element</typeparam> /// <param name="tuple">Tuple that must be of size 2</param> /// <returns>Equivalent tuple, with its elements converted to the specified types</returns> public static STuple <T1, T2> As <T1, T2>([NotNull] this ITuple tuple) { tuple.OfSize(2); return(new STuple <T1, T2>( tuple.Get <T1>(0), tuple.Get <T2>(1) )); }
public static void Deconstruct <T1, T2, T3, T4, T5>(this ITuple value, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5) { value.OfSize(5); item1 = value.Get <T1>(0); item2 = value.Get <T2>(1); item3 = value.Get <T3>(2); item4 = value.Get <T4>(3); item5 = value.Get <T5>(4); }
/// <summary>Returns a typed version of a tuple of size 4</summary> /// <typeparam name="T1">Expected type of the first element</typeparam> /// <typeparam name="T2">Expected type of the second element</typeparam> /// <typeparam name="T3">Expected type of the third element</typeparam> /// <typeparam name="T4">Expected type of the fourth element</typeparam> /// <param name="tuple">Tuple that must be of size 4</param> /// <returns>Equivalent tuple, with its elements converted to the specified types</returns> public static STuple <T1, T2, T3, T4> As <T1, T2, T3, T4>([NotNull] this ITuple tuple) { tuple.OfSize(4); return(new STuple <T1, T2, T3, T4>( tuple.Get <T1>(0), tuple.Get <T2>(1), tuple.Get <T3>(2), tuple.Get <T4>(3) )); }
public static void Deconstruct <T1, T2, T3, T4, T5, T6, T7>(this ITuple value, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5, out T6 item6, out T7 item7) { value.OfSize(7); item1 = value.Get <T1>(0); item2 = value.Get <T2>(1); item3 = value.Get <T3>(2); item4 = value.Get <T4>(3); item5 = value.Get <T5>(4); item6 = value.Get <T6>(5); item7 = value.Get <T7>(6); }
public T FromTuple(ITuple tuple) { return(tuple.OfSize(1).Get <T>(0)); }
public static void Deconstruct <T1>(this ITuple value, out T1 item1) { item1 = value.OfSize(1).Get <T1>(0); }
/// <summary>Execute a lambda Function with the content of this tuple</summary> /// <param name="tuple">Tuple of size 1</param> /// <param name="lambda">Action that will be passed the content of this tuple as parameters</param> /// <returns>Result of calling <paramref name="lambda"/> with the items of this tuple</returns> /// <exception cref="InvalidOperationException">If <paramref name="tuple"/> has not the expected size</exception> public static TResult With <T1, TResult>([NotNull] this ITuple tuple, [NotNull] Func <T1, TResult> lambda) { return(lambda(tuple.OfSize(1).Get <T1>(0))); }