public static bool TryGetUnit(String s, out int value) { value = -1; try { ChineseUnit u = (ChineseUnit)EnumUtils.enumValueOf(s, typeof(ChineseUnit)); value = (int)u; return(true); } catch (Exception) { return(false); } }
public override void Interpret(MoneyContext context) { int unit = context.GetNumIntList().Count - 1; if (unit == 0) { return; } else if (unit % 4 > 0) { unit = unit % 4; } Cu = (ChineseUnit)unit; if ((currentNumber != null) && (currentNumber.IsZero())) { if (this.LessThan4()) { return; } else if (this.GreatThan3()) { try { ChineseUnit preCu = (ChineseUnit)EnumUtils.enumValueOf(context.GetChineseCharList().First(), typeof(ChineseUnit)); if ((((int)preCu) > 3) && (this.GreatThan3())) { return; } } catch { } context.GetChineseCharList().RemoveFirst(); } } try { ChineseUnit preCu = (ChineseUnit)EnumUtils.enumValueOf(context.GetChineseCharList().First(), typeof(ChineseUnit)); if ((((int)preCu) > 3) && (this.GreatThan3())) { return; } } catch { } context.GetChineseCharList().AddFirst(EnumUtils.stringValueOf(Cu)); }
public override void Interpret(MoneyContext context) { int unit = context.GetNumIntList().Count - 1; if (unit == 0) return; else if (unit % 4 > 0) unit = unit % 4; Cu = (ChineseUnit)unit; if ((currentNumber != null) && (currentNumber.IsZero())) { if (this.LessThan4()) return; else if (this.GreatThan3()) { try { ChineseUnit preCu = (ChineseUnit)EnumUtils.enumValueOf(context.GetChineseCharList().First(), typeof(ChineseUnit)); if ((((int)preCu) > 3) && (this.GreatThan3())) return; } catch { } context.GetChineseCharList().RemoveFirst(); } } try { ChineseUnit preCu = (ChineseUnit)EnumUtils.enumValueOf(context.GetChineseCharList().First(), typeof(ChineseUnit)); if ((((int)preCu) > 3) && (this.GreatThan3())) return; } catch { } context.GetChineseCharList().AddFirst(EnumUtils.stringValueOf(Cu)); }