diff --git a/Amrv.ConfigurableCompany/API/ConfigTypes/DecimalRangeType.cs b/Amrv.ConfigurableCompany/API/ConfigTypes/DecimalRangeType.cs index 5d652c3..99c6e04 100644 --- a/Amrv.ConfigurableCompany/API/ConfigTypes/DecimalRangeType.cs +++ b/Amrv.ConfigurableCompany/API/ConfigTypes/DecimalRangeType.cs @@ -4,6 +4,7 @@ using System; using System.Collections; using System.Globalization; +using System.Reflection; using System.Runtime.CompilerServices; namespace Amrv.ConfigurableCompany.API.ConfigTypes @@ -13,6 +14,8 @@ public class DecimalRangeType : CType private static readonly Type TYPE_CONVERTABLE = typeof(IConvertible); private static readonly Type TYPE_ITUPLE = typeof(ITuple); private static readonly Type TYPE_TUPLE_T_T = typeof(Tuple<,>); + private static readonly MethodInfo METHOD_TUPLE = typeof(DecimalRangeType).GetMethod("TupleOfTypes", BindingFlags.Static | BindingFlags.NonPublic); + private static readonly MethodInfo METHOD_VALUE_TUPLE = typeof(DecimalRangeType).GetMethod("ValueTupleOfTypes", BindingFlags.Static | BindingFlags.NonPublic); public readonly double Min; public readonly double Max; @@ -163,5 +166,25 @@ protected internal override bool Serialize(in object item, out string data) data = default; return false; } + + private static object GenericTuple(object a, object b) + { + return METHOD_TUPLE.MakeGenericMethod(a.GetType(), b.GetType()).Invoke(null, [a, b]); + } + + private static object GenericValueTuple(object a, object b) + { + return METHOD_VALUE_TUPLE.MakeGenericMethod(a.GetType(), b.GetType()).Invoke(null, [a, b]); + } + + private static Tuple TupleOfTypes(T1 a, T2 b) + { + return Tuple.Create(a, b); + } + + private static ValueTuple ValueTupleOfTypes(T1 a, T2 b) + { + return ValueTuple.Create(a, b); + } } }