예제 #1
0
 private T Convert <T>(T origin, out RedisValue redisVal)
 {
     redisVal = RedisValueConverter.ConvertTo(origin);
     return(RedisValueConverter.ConvertFrom <T>(redisVal));
 }
예제 #2
0
 /// <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));
 }
예제 #3
0
 public void ConvertTypeUnregisteredShouldThrow()
 {
     Assert.ThrowsException <OhmSharpConvertionException>(() => RedisValueConverter.ConvertTo(new object()));
     Assert.ThrowsException <OhmSharpConvertionException>(() => RedisValueConverter.ConvertFrom <object>(RedisValue.EmptyString));
 }