public static IFolderRanges CreateStringFolderRanges(TreeNode ownerTreeNode, List<Tuple<string, string>> ranges, bool includeWildCard) { StringFolderRanges folderRanges = new StringFolderRanges(); int counter = 0; string lastMaxValue = null; foreach (Tuple<string, string> range in ranges) { string minValue = ""; string maxValue = ""; bool isMinOpenEnded = range.Item1 == ""; bool isMaxOpenEnded = range.Item2 == ""; if (range.Item1 != "") { if (range.Item1.Length != 1) { ownerTreeNode.AddValidationError("TreeValidationError.Range.WrongFormat"); return null; } else { minValue = range.Item1; } } if (range.Item2 != "") { if (range.Item2.Length != 1) { ownerTreeNode.AddValidationError("TreeValidationError.Range.WrongFormat"); return null; } else { maxValue = range.Item2; } } if ((isMinOpenEnded == false) && (isMaxOpenEnded == false) && (string.Compare(minValue, maxValue) >= 0)) { ownerTreeNode.AddValidationError("TreeValidationError.Range.MinMaxError", minValue, maxValue); return null; } if (lastMaxValue == null) { lastMaxValue = maxValue; } else if (string.Compare(lastMaxValue, minValue) >= 0) { ownerTreeNode.AddValidationError("TreeValidationError.Range.NextRangeError"); } StringFolderRange folderRange = new StringFolderRange( counter++, minValue, maxValue, isMinOpenEnded, isMaxOpenEnded ); folderRanges.AddFolderRange(folderRange); } if (includeWildCard) { StringFolderRange folderRange = new StringFolderRange( -1, "", "", false, false ); folderRanges.AddFolderRange(folderRange); } return folderRanges; }
public static IFolderRanges CreateStringFolderRanges(TreeNode ownerTreeNode, List <Tuple <string, string> > ranges, bool includeWildCard) { StringFolderRanges folderRanges = new StringFolderRanges(); int counter = 0; string lastMaxValue = null; foreach (Tuple <string, string> range in ranges) { string minValue = ""; string maxValue = ""; bool isMinOpenEnded = range.Item1 == ""; bool isMaxOpenEnded = range.Item2 == ""; if (range.Item1 != "") { if (range.Item1.Length != 1) { ownerTreeNode.AddValidationError("TreeValidationError.Range.WrongFormat"); return(null); } else { minValue = range.Item1; } } if (range.Item2 != "") { if (range.Item2.Length != 1) { ownerTreeNode.AddValidationError("TreeValidationError.Range.WrongFormat"); return(null); } else { maxValue = range.Item2; } } if ((isMinOpenEnded == false) && (isMaxOpenEnded == false) && (string.Compare(minValue, maxValue) >= 0)) { ownerTreeNode.AddValidationError("TreeValidationError.Range.MinMaxError", minValue, maxValue); return(null); } if (lastMaxValue == null) { lastMaxValue = maxValue; } else if (string.Compare(lastMaxValue, minValue) >= 0) { ownerTreeNode.AddValidationError("TreeValidationError.Range.NextRangeError"); } StringFolderRange folderRange = new StringFolderRange( counter++, minValue, maxValue, isMinOpenEnded, isMaxOpenEnded ); folderRanges.AddFolderRange(folderRange); } if (includeWildCard) { StringFolderRange folderRange = new StringFolderRange( -1, "", "", false, false ); folderRanges.AddFolderRange(folderRange); } return(folderRanges); }