private T Convert <T>(T origin, out RedisValue redisVal) { redisVal = RedisValueConverter.ConvertTo(origin); return(RedisValueConverter.ConvertFrom <T>(redisVal)); }
/// <summary> /// Convert object to RedisValue if supported /// </summary> /// <param name="value">object to convert</param> /// <param name="provider">optional provider controls how value is converted</param> /// <returns>RedisValue contains content of the object</returns> /// <exception cref="OhmSharpConvertionException">throw if convertion failed</exception> public static RedisValue ToRedisValue(this object value, IFormatProvider provider = null) { return(RedisValueConverter.ConvertTo(value, value.GetType(), provider)); }
public void ConvertTypeUnregisteredShouldThrow() { Assert.ThrowsException <OhmSharpConvertionException>(() => RedisValueConverter.ConvertTo(new object())); Assert.ThrowsException <OhmSharpConvertionException>(() => RedisValueConverter.ConvertFrom <object>(RedisValue.EmptyString)); }