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