private static object ParseParameterValue()

in src/extensions/helper_functions_extension/HelperFunctionFactory.cs [206:243]


        private static object ParseParameterValue(string parameterValue, Type parameterType)
        {
            if (IsArrayType(parameterType))
            {
                Type elementType = parameterType.GetElementType()!;
                return CreateGenericCollectionFromJsonArray(parameterValue, typeof(Array), elementType);
            }

            if (IsTuppleType(parameterType))
            {
                Type elementType = parameterType.GetGenericArguments()[0];
                return CreateTuppleTypeFromJsonArray(parameterValue, elementType);
            }

            if (IsGenericListOrEquivalentType(parameterType))
            {
                Type elementType = parameterType.GetGenericArguments()[0];
                return CreateGenericCollectionFromJsonArray(parameterValue, typeof(List<>), elementType);
            }

            switch (Type.GetTypeCode(parameterType))
            {
                case TypeCode.Boolean: return bool.Parse(parameterValue!);
                case TypeCode.Byte: return byte.Parse(parameterValue!);
                case TypeCode.Decimal: return decimal.Parse(parameterValue!);
                case TypeCode.Double: return double.Parse(parameterValue!);
                case TypeCode.Single: return float.Parse(parameterValue!);
                case TypeCode.Int16: return short.Parse(parameterValue!);
                case TypeCode.Int32: return int.Parse(parameterValue!);
                case TypeCode.Int64: return long.Parse(parameterValue!);
                case TypeCode.SByte: return sbyte.Parse(parameterValue!);
                case TypeCode.UInt16: return ushort.Parse(parameterValue!);
                case TypeCode.UInt32: return uint.Parse(parameterValue!);
                case TypeCode.UInt64: return ulong.Parse(parameterValue!);
                case TypeCode.String: return parameterValue!;
                default: return Convert.ChangeType(parameterValue!, parameterType);
            }
        }