Exemple #1
0
 /// <summary>
 /// Change the type of a value.
 /// </summary>
 /// <typeparam name="T">The type of the value to change to.</typeparam>
 /// <param name="value">The value to convert.</param>
 /// <param name="expected">The converted value.</param>
 public void VerifyChangeType <T>(object value, T expected)
 {
     Assert.AreEqual(
         expected,
         TypeExtensions.ChangeType(value, typeof(T)));
 }
Exemple #2
0
        private T GetQueryValue <T>(string key, T defaultValue)
        {
            var stringValue = GetQueryStringValue(key);

            return(!string.IsNullOrEmpty(stringValue) ? (T)TypeExtensions.ChangeType(stringValue, typeof(T)) : defaultValue);
        }
Exemple #3
0
 /// <summary>
 ///     转换主键类型。
 /// </summary>
 /// <param name="value"></param>
 /// <returns></returns>
 private static object ParseEntityKey(string value)
 {
     return(TypeExtensions.ChangeType(value, typeof(TKey)));
 }