/// <summary>
 /// Parses a Redis string to a <see cref="Nullable{DateTime}"/> value, if string is not null or empty. If the string is null or empty, returns null.
 /// </summary>
 /// <param name="value">The string value to parse.</param>
 /// <returns>The parsed <see cref="Nullable{DateTime}"/> value.</returns>
 /// <exception cref="ArgumentException">Parameter <paramref name="value"/> is neither null nor empty and cannot be parsed to <see cref="Nullable{DateTime}"/>.</exception>
 public static DateTime?ParseDateTimeOrNull(string value)
 {
     if (string.IsNullOrWhiteSpace(value))
     {
         return(null);
     }
     else
     {
         return(RedisConverter.ParseDateTime(value));
     }
 }
        /// <summary>
        /// Parses a Redis string to an object.
        /// </summary>
        /// <param name="value">The string value to parse.</param>
        /// <param name="toType">The type of the object to parse.</param>
        /// <returns>The parsed object.</returns>
        /// <exception cref="ArgumentNullException">Parameter <paramref name="toType"/> is null.</exception>
        /// <exception cref="NotSupportedException">Type <paramref name="toType" /> is not supported.</exception>
        public static object ParseValue(string value, Type toType)
        {
            if (toType == null)
            {
                throw new ArgumentNullException("toType");
            }

            if (toType == typeof(string))
            {
                return(value);
            }

            if (toType.IsGenericType && toType.GetGenericTypeDefinition() == typeof(Nullable <>))
            {
                if (string.IsNullOrEmpty(value))
                {
                    return(null);
                }

                toType = toType.GetGenericArguments()[0];
            }

            if (toType == typeof(int))
            {
                return(RedisConverter.ParseInteger(value));
            }

            if (toType == typeof(long))
            {
                return(RedisConverter.ParseLong(value));
            }

            if (toType == typeof(float))
            {
                return(RedisConverter.ParseFloat(value));
            }

            if (toType == typeof(double))
            {
                return(RedisConverter.ParseDouble(value));
            }

            if (toType == typeof(Guid))
            {
                return(RedisConverter.ParseGuid(value));
            }

            if (toType == typeof(TimeSpan))
            {
                return(RedisConverter.ParseTimeSpan(value));
            }

            if (toType == typeof(DateTime))
            {
                return(RedisConverter.ParseDateTime(value));
            }

            if (toType == typeof(bool))
            {
                return(RedisConverter.ParseBoolean(value));
            }

            if (toType.IsEnum)
            {
                return(RedisConverter.ParseEnum(value, toType));
            }

            if (toType == typeof(Type))
            {
                return(RedisConverter.ParseType(value));
            }

            if (toType == typeof(Version))
            {
                return(RedisConverter.ParseVersion(value));
            }

            throw new NotSupportedException <Type>(toType);
        }