public void ConverterTest1() { var mn = TypeCast.ChangeType <MeasuredNumber>("100m"); Assert.AreEqual(100, mn.Number); Assert.AreEqual(MeasureUnit.Parse("m"), mn.Unit); }
public void ConverterTest2() { var mn = TypeCast.ChangeType <MeasuredNumber>("0.9m/(s*s)"); Assert.AreEqual(0.9, mn.Number); Assert.AreEqual(MeasureUnit.Parse("m/(s*s)"), mn.Unit); }
public void TestConvertFrom() { string str = "Class,Struct"; AttributeTargets t = TypeCast.ChangeType <AttributeTargets>(str); Assert.IsTrue(t == (AttributeTargets.Class | AttributeTargets.Struct)); }
public T ReadValue <T>(string section, string key) where T : struct { try { string val = _cfg[section][key]; return(TypeCast.ChangeType <T>(val)); } catch (Exception ex) { throw ExceptionHelper.CreateWrapException(ex, section, key); } }
public T?TryReadValue <T>(string section, string key) where T : struct { if (ExistsKey(section, key)) { string val = _cfg[section][key]; return(TypeCast.ChangeType <T>(val)); } else { return(default(T)); } }
public long QueryCount(IQuery query) { try { string sql = _emit.QueryCount(query); _log.Debug(sql); object val = _exe.ExecuteScalar(sql); return(TypeCast.ChangeType <long>(val)); } catch (Exception ex) { throw ex.CreateWrapException <ORMException>(); } }
public void ConverterTest3() { var mn = TypeCast.ChangeType <MeasuredNumber>(100); }
public void ConverterOverflowTest() { Percentage p = Percentage.Parse("25700%"); TypeCast.ChangeType <Byte>(p); }
public void ConverterTest3() { TypeCast.ChangeType <Percentage>(1); }
public void ConverterTest2() { TypeCast.ChangeType <Percentage>("0.9"); }
public void ConverterTest1() { TypeCast.ChangeType <Percentage>("90%"); }