Пример #1
0
        public Dictionary <ColumnConfig, string> Split(string content)
        {
            IList <string> values = null;

            if (Type == SplitType.FixedWidth)
            {
                values = content.SplitFixedWidth(Width).ToList();
            }
            else
            {
                values = SplitPattern.Split(content).ToList();
            }
            var ret = new Dictionary <ColumnConfig, string>();

            for (int i = 0; i < SplitColumns.Count; i++)
            {
                if (SplitColumns[i].SplitConfig?.SubColumns?.Count > 0)
                {
                    var subColumns = SplitColumns[i].SplitConfig.Split(values[i]);
                    foreach (var c in subColumns)
                    {
                        ret.Add(c.Key, c.Value);
                    }
                }
                else
                {
                    ret.Add(SplitColumns[i], values[i]);
                }
            }
            return(ret);
        }
Пример #2
0
        public bool CanSplit(string content)
        {
            if (String.IsNullOrWhiteSpace(content))
            {
                return(false);
            }

            return((Type == SplitType.FixedWidth) ? content.Length > Width : SplitPattern.IsMatch(content));
        }