// CNY1.00=USD0.22222 public static RateItem Parse(string strText) { if (strText.IndexOf('=') == -1) { throw new Exception("对照事项格式不正确,缺乏等号。'" + strText + "'"); } List <string> parts = StringUtil.ParseTwoPart(strText, "="); string strSource = parts[0].Trim(); string strTarget = parts[1].Trim(); RateItem result = new RateItem(); result.Source = DoubleCurrencyItem.Parse(strSource); result.Target = DoubleCurrencyItem.Parse(strTarget); return(result); }
public static DoubleCurrencyItem Parse(string strText) { string strError = ""; string strPrefix = ""; string strValue = ""; string strPostfix = ""; int nRet = PriceUtil.ParsePriceUnit(strText, out strPrefix, out strValue, out strPostfix, out strError); if (nRet == -1) { throw new Exception(strError); } double value = 0; try { value = Convert.ToDouble(strValue); } catch { strError = "数字 '" + strValue + "' 格式不正确"; throw new Exception(strError); } DoubleCurrencyItem item = new DoubleCurrencyItem(); item.Prefix = strPrefix; item.Postfix = strPostfix; item.Value = value; return(item); }