public static SplitOutputInfo Create( SplitData splitData, OutputCaptions captions = null, string prefixSeparator = null) { int splitCount = 0; int maxGroupNameLength = 0; int maxIndex = 0; int maxLength = 0; foreach (SplitItem splitItem in splitData.Items) { if (splitItem.IsGroup) { if (!splitData.OmitGroups) { maxGroupNameLength = Math.Max(maxGroupNameLength, splitItem.Name.Length); } } else { splitCount++; } maxIndex = Math.Max(maxIndex, splitItem.Index); maxLength = Math.Max(maxLength, splitItem.Length); } int splitWidth = Math.Max(splitCount.GetDigitCount(), maxGroupNameLength); int indexWidth = (maxIndex > 0) ? maxIndex.GetDigitCount() : 0; int lengthWidth = (maxLength > 0) ? maxLength.GetDigitCount() : 0; return(new SplitOutputInfo(splitWidth, indexWidth, lengthWidth, captions, prefixSeparator)); }
private SplitOutputInfo( int splitWidth, int indexWidth, int lengthWidth, OutputCaptions captions = null, string prefixSeparator = null) { SplitWidth = splitWidth; IndexWidth = indexWidth; LengthWidth = lengthWidth; Captions = captions ?? OutputCaptions.Default; PrefixSeparator = prefixSeparator ?? ":"; }
private MatchOutputInfo( int groupNumber, int matchWidth, int groupWidth, int captureWidth, int indexWidth, int lengthWidth, OutputCaptions captions = null, string prefixSeparator = null) { GroupNumber = groupNumber; MatchWidth = matchWidth; GroupWidth = groupWidth; CaptureWidth = captureWidth; IndexWidth = indexWidth; LengthWidth = lengthWidth; Captions = captions ?? OutputCaptions.Default; PrefixSeparator = prefixSeparator ?? ":"; }
public static MatchOutputInfo Create( MatchData matchData, int groupNumber = -1, bool includeGroupNumber = true, bool includeCaptureNumber = true, OutputCaptions captions = null, string prefixSeparator = null) { int matchWidth = Math.Max(matchData.Items.Count, 0).GetDigitCount(); int groupWidth = 0; int captureWidth = 0; int indexWidth = 0; int lengthWidth = 0; int maxGroupNameLength = 0; int maxCaptureCount = 0; int maxIndex = 0; int maxLength = 0; foreach (MatchItem matchItem in matchData.Items) { foreach (GroupItem groupItem in matchItem.GroupItems) { if (!groupItem.Success) { continue; } if (groupNumber >= 0 && groupNumber != groupItem.Number) { continue; } if (includeGroupNumber) { maxGroupNameLength = Math.Max(maxGroupNameLength, groupItem.Name.Length); } if (includeCaptureNumber) { maxCaptureCount = Math.Max(maxCaptureCount, groupItem.Captures.Count); } foreach (Capture capture in groupItem.Captures) { maxIndex = Math.Max(maxIndex, capture.Index); maxLength = Math.Max(maxLength, capture.Length); } } } if (maxGroupNameLength > 0) { groupWidth = maxGroupNameLength; } if (maxCaptureCount > 1) { captureWidth = maxCaptureCount.GetDigitCount(); } if (maxIndex > 0) { indexWidth = maxIndex.GetDigitCount(); } if (maxLength > 0) { lengthWidth = maxLength.GetDigitCount(); } return(new MatchOutputInfo(groupNumber, matchWidth, groupWidth, captureWidth, indexWidth, lengthWidth, captions, prefixSeparator)); }