Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="splitCount"></param>
        /// <param name="creator"></param>
        /// <returns></returns>
        public IEnumerable <T> Load(string fileName, int splitCount, Func <string[], T> creator = null)
        {
            try
            {
                creator = creator ?? _Creator;
                Items   = null;
                if (File.Exists(fileName))
                {
                    var lines = File.ReadAllLines(fileName);
                    Items = (FilterSource?.Invoke(lines) ?? lines)
                            .Select(i => creator(i.Split(Separator.ToCharArray(), splitCount, StringSplitOptions.RemoveEmptyEntries)))
                            .ToArray();
                }
            }
            catch (Exception ex)
            {
                this.Error(ex);
            }

            return(Items);
        }