コード例 #1
0
        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();
        }
コード例 #2
0
        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();
        }
コード例 #3
0
        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));
        }
コード例 #4
0
 public bool IsTableRow(string row)
 {
     return(ColSplitStrings.Any(row.Contains));
 }