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