virtual public int GetUnitIDByDigitsLength(int DigitsLength) { if (MaxDigitsConfigured < DigitsLength) { throw new InvalidProgramException("Given Input Number is exceeding Max number Digits Configured...."); } int UnitMetaInfoDictionaryCount = UnitMetaInfoDictionary.Count; for (int index = 1; index <= UnitMetaInfoDictionaryCount; index++) { UnitMetaInfo unitMetaInfoTmp = null; if (GetUnitMetaInfo(index, out unitMetaInfoTmp) == false) { throw new InvalidProgramException("Possibly Number system not configured properly.."); } int CurrUnitDigitsMaxLength = unitMetaInfoTmp.GetDigitsMaxLength(); if (CurrUnitDigitsMaxLength >= DigitsLength) { return(unitMetaInfoTmp.GetUnitID()); } } throw new InvalidProgramException("Possibly Number system not configured properly.."); }
void SegregateIntoUnitsForInteger() { if (string.IsNullOrEmpty(IntegerPartofInputNumber) == true) { IntegerPartofInputNumberText = "Zero"; } string IntegerPartofInputNumberTmp = IntegerPartofInputNumber; int nTotalLength = IntegerPartofInputNumberTmp.Length; int nCurrentUnitLength = nTotalLength; string TempNumberStr = IntegerPartofInputNumber; int UnitID = NumberSystem.GetUnitIDByDigitsLength(nTotalLength); int startIndex = 0, EndIndex = 0, ActualUnitLength = 0, ActualFullLength; ActualFullLength = nTotalLength; for (; UnitID > 0; UnitID--) { UnitMetaInfo CurrUnitMetaInfo = null; if (NumberSystem.GetUnitMetaInfo(UnitID, out CurrUnitMetaInfo) == false) { throw new InvalidProgramException(""); } if (startIndex == 0) { ActualUnitLength = IntegerPartofInputNumberTmp.Length - CurrUnitMetaInfo.GetDigitsMaxLength() + CurrUnitMetaInfo.GetUnitMaxLength(); } else { ActualUnitLength = CurrUnitMetaInfo.GetUnitMaxLength(); } EndIndex = startIndex + ActualUnitLength; TempNumberStr = IntegerPartofInputNumberTmp.Substring(startIndex, ActualUnitLength); // Convert string to Integer datatype int TempNumber = 0; if (Int32.TryParse(TempNumberStr, out TempNumber) == false) { continue; } // Check not exceed 999 if (TempNumber != 0) { bool IsConjuctionRequired = UnitID == 1 ? true : false; IntegerPartofInputNumberText = IntegerPartofInputNumberText + NumberSystem.ToText(TempNumber, CurrUnitMetaInfo.GetUnitName(), IsConjuctionRequired); } startIndex = EndIndex; } }
public override void Build() { BuildRepetetiveNumbers(); BuildUnitMetaInfo(); int lastUnitID = UnitMetaInfoDictionary.Count(); UnitMetaInfo unitMetaInfo = null; if (GetUnitMetaInfo(lastUnitID, out unitMetaInfo) == false) { throw new InvalidProgramException("Possibly Number system not configured properly.."); } MaxDigitsConfigured = unitMetaInfo.GetDigitsMaxLength(); CurrencyName = "DOLLAR"; CoinName = "CENT"; }