TupleUtilities
TupleUtilities.CreateValueTupleType(types) creates a ValueTuple.
Type tupleType = TupleUtilities.CreateValueTupleType(typeof(int), typeof(int), typeof(int), typeof(int), typeof(int), typeof(int), typeof(int), typeof(int), typeof(int), typeof(int), typeof(int), typeof(int));
System.ValueTuple`8[System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.ValueTuple`5[System.Int32,System.Int32,System.Int32,System.Int32,System.Int32]]
TupleUtilities.GetParameterTypes(tupleType) extracts parameters from ValueTuple.
Type[] parameterTypes = TupleUtilities.GetParameterTypes(tupleType);
Result
System.Int32 System.Int32 System.Int32 System.Int32 System.Int32 System.Int32 System.Int32 System.Int32 System.Int32 System.Int32 System.Int32 System.Int32
TupleUtilities.GetParameterTypes(tupleType) extracts ValueTuple types.
Type[] tupleTypes = TupleUtilities.GetTupleTypes(tupleType);
System.ValueTuple`8[System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.ValueTuple`5[System.Int32,System.Int32,System.Int32,System.Int32,System.Int32]] System.ValueTuple`5[System.Int32,System.Int32,System.Int32,System.Int32,System.Int32]
Full Example
Full example
using System;
using Avalanche.Utilities;
public class tupleutilities
{
public static void Run()
{
{
// <01>
Type tupleType = TupleUtilities.CreateValueTupleType(typeof(int), typeof(int), typeof(int), typeof(int), typeof(int), typeof(int), typeof(int), typeof(int), typeof(int), typeof(int), typeof(int), typeof(int));
// </01>
Console.WriteLine(tupleType);
// System.ValueTuple`8[System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.ValueTuple`5[System.Int32,System.Int32,System.Int32,System.Int32,System.Int32]]
// <02>
Type[] parameterTypes = TupleUtilities.GetParameterTypes(tupleType);
// </02>
foreach (var type in parameterTypes)
Console.WriteLine(type);
// <03>
Type[] tupleTypes = TupleUtilities.GetTupleTypes(tupleType);
// </03>
foreach (var type in tupleTypes)
Console.WriteLine(type);
}
}
}