public void RectifyRange() { string startSub = RangeStart.Replace(BaseValue, ""); string endSub = RangeEnd.Replace(BaseValue, ""); if (startSub == "" || endSub == "") //In the cases where one end IS the base value (eg 5.10-5.11) { return; } else if (startSub == "-" && endSub == "+") { return; } else if (endSub == "-" && startSub == "+") { RangeStart = BaseValue + "-"; RangeEnd = BaseValue + "+"; } else if (endSub[0] < startSub[0]) //Compare letters by char value { RangeStart = BaseValue + endSub; RangeEnd = BaseValue + startSub; } }
public List <string> GetRangeValues() { if (!IsRange) { return new List <string> { Value } } ; else { List <string> result = new List <string>(); string startSub = RangeStart.Replace(BaseValue, ""); string endSub = RangeEnd.Replace(BaseValue, ""); int rangeStart = Convert.ToInt32(Regex.Match(RangeStart, @"\d+").Value); int rangeEnd = Convert.ToInt32(Regex.Match(RangeEnd, @"\d+").Value); for (int i = rangeStart; i <= rangeEnd; i++) { if (startSub == "" || endSub == "") { if (System == GradeSystem.Hueco) { result.Add($"V{i}"); } else if (System == GradeSystem.YDS) { result.Add($"5.{i}"); } } else if (startSub == "-") { if (System == GradeSystem.Hueco) { result.Add($"V{i}-"); result.Add($"V{i}"); result.Add($"V{i}+"); } else if (System == GradeSystem.YDS) { result.Add($"5.{i}-"); result.Add($"5.{i}"); result.Add($"5.{i}+"); } } else { char startChar = i == rangeStart ? startSub[0] : 'a'; char endChar = i == rangeEnd ? endSub[0] : 'd'; for (char c = startChar; c <= endChar; c++) { if (System == GradeSystem.Hueco) { result.Add($"V{i}{c}"); } else if (System == GradeSystem.YDS) { result.Add($"5.{i}{c}"); } } } } return(result); } }