public virtual Numbers BuildNumbers(string line) { try { string[] str = line.Split(','); int day = int.Parse(str[DayIndex]); int month = int.Parse(str[MonthIndex]); int year = int.Parse(str[YearIndex]); DateTime date = new DateTime(year, month, day); if (year < 1000) { throw new Exception(year.ToString() + " " + line); } int specialNumber = SpecialNumberIndex != DefaultNumber?int.Parse(str[SpecialNumberIndex]) : DefaultNumber; int specialPlay = SpecialPlayIndex != DefaultNumber && SpecialPlayIndex < str.Length ? int.Parse(str[SpecialPlayIndex]) : DefaultNumber; int[] numbers = NumbersIndexes.ToList().Select(ni => int.Parse(str[ni])).ToArray(); return(new Numbers(date, numbers, DefaultNumber, specialNumber, specialPlay)); } catch (Exception ex) { Error = ex.Message; } return(null); }
public void UpdateIndex(int patternIndex) { switch (Pattern[patternIndex]) { case PatternSection.day: DayIndex = patternIndex; break; case PatternSection.month: MonthIndex = patternIndex; break; case PatternSection.year: YearIndex = patternIndex; break; case PatternSection.specialnumber: SpecialNumberIndex = patternIndex; break; case PatternSection.plays: SpecialPlayIndex = patternIndex; break; case PatternSection.number: NumbersIndexes.Add(patternIndex); break; default: break; } }