public static object ToValue(string value, SharpValueType type, bool autoType = false)
        {
            if (value == null)
            {
                return(null);
            }

            switch (type)
            {
            case SharpValueType.None:
                if (autoType)
                {
                    return(ToValue(value, SharpValueType.Auto));
                }
                return(value);

            case SharpValueType.String:
                return(value);

            case SharpValueType.Bool:
            {
                bool boolResult;
                if (bool.TryParse(value, out boolResult))
                {
                    return(boolResult);
                }

                return(value);
            }

            case SharpValueType.Int:
            {
                int intResult;
                if (int.TryParse(value, out intResult))
                {
                    return(intResult);
                }

                return(value);
            }

            case SharpValueType.Long:
            {
                long longResult;
                if (long.TryParse(value, out longResult))
                {
                    return(longResult);
                }

                return(value);
            }

            case SharpValueType.Date:
            case SharpValueType.DateTime:
            case SharpValueType.TimeStamp:
            {
                DateTime dateResult;
                if (DateTime.TryParse(value, out dateResult))
                {
                    return(dateResult);
                }

                return(value);
            }

            case SharpValueType.TimeSpan:
            {
                TimeSpan timeSpanResult;
                if (TimeSpan.TryParse(value, out timeSpanResult))
                {
                    return(timeSpanResult);
                }
                return(value);
            }

            case SharpValueType.Double:
            {
                double doubleResult;
                if (double.TryParse(value, out doubleResult))
                {
                    return(doubleResult);
                }
                return(value);
            }

            case SharpValueType.Decimal:
            {
                Decimal decimalResult;
                if (Decimal.TryParse(value, out decimalResult))
                {
                    return(decimalResult);
                }
                return(value);
            }

            case SharpValueType.NumericString:
            {
                if (NumericString.CanEncode(value))
                {
                    return(new NumericString(value));
                }
                return(value);
            }

            case SharpValueType.List:
            {
                return(EncodedString.ParseList(value, trimStrings: true));
            }

            case SharpValueType.Object:
            {
                return(EncodedString.ParseObject(value));
            }
            }

            return(value);
        }