public TextAssetHelper(IEnumerable <string> rowSplitStrings = null, IEnumerable <string> colSplitStrings = null) { int comp(string a, string b) => b.Length.CompareTo(a.Length); List <string> tmpList = new List <string>(); // row split strings tmpList.AddRange(rowSplitStrings?.ToArray() ?? new string[0]); tmpList.Sort(comp); RowSplitStrings = tmpList.ToArray(); // col split strings tmpList.Clear(); tmpList.AddRange(colSplitStrings?.ToArray() ?? new string[0]); tmpList.Sort(comp); ColSplitStrings = tmpList.ToArray(); // invalid col strings tmpList.Clear(); tmpList.AddRange(RowSplitStrings); tmpList.AddRange(ColSplitStrings); tmpList.Sort(comp); InvalidColStrings = tmpList.ToArray(); Enabled = ColSplitStrings.Any() && RowSplitStrings.Any(); }
public TextAssetTableHelper(IEnumerable <string> rowSplitStrings = null, IEnumerable <string> colSplitStrings = null, Encoding encoding = null) { TextAssetEncoding = encoding ?? Encoding.UTF8; int Comp(string a, string b) { return(b.Length.CompareTo(a.Length)); } var tmpList = new List <string>(); // row split strings tmpList.AddRange(rowSplitStrings?.ToArray() ?? new string[0]); tmpList.Sort(Comp); _rowSplitStrings = tmpList.ToArray(); // col split strings tmpList.Clear(); tmpList.AddRange(colSplitStrings?.ToArray() ?? new string[0]); tmpList.Sort(Comp); _colSplitStrings = tmpList.ToArray(); // invalid col strings tmpList.Clear(); tmpList.AddRange(RowSplitStrings); tmpList.AddRange(ColSplitStrings); tmpList.Sort(Comp); _invalidColStrings = tmpList.ToArray(); Enabled = ColSplitStrings.Any() && RowSplitStrings.Any(); }
public bool IsTable(string table) { // possible table is only 1 row, but it needs to have at least 1 column break if (string.IsNullOrEmpty(table)) { return(false); } var row = table.Split(_rowSplitStrings, StringSplitOptions.None).FirstOrDefault(); return(row != null && ColSplitStrings.Any(row.Contains)); }
public bool IsTableRow(string row) { return(ColSplitStrings.Any(row.Contains)); }