using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;

namespace PlantBox.Shared.Extensions
{
    public static class CommandSerializeExtensions
    {
        // Array extensions
        public static (T first, T second) ToTuple<T>(this T[] array)
        {
            return (array[0], array[1]);
        }

        // String conversion
        public static T ToEnumValue<T>(this string argument)
        {
            return (T)Enum.Parse(typeof(T), argument, true);
        }
        public static int ToInt(this string argument)
        {
            return int.Parse(argument, CultureInfo.InvariantCulture);
        }
        public static double ToDouble(this string argument)
        {
            return double.Parse(argument, CultureInfo.InvariantCulture);
        }

        // Double conversion
        public static string ToArgument(this double argument)
        {
            return argument.ToString(CultureInfo.InvariantCulture);
        }

        // Int conversion
        public static string ToArgument(this int argument)
        {
            return argument.ToString(CultureInfo.InvariantCulture);
        }
    }
}
