예제 #1
0
        public IEnumerable <TResult> GetData <TResult>(Func <TSource, TResult> selector)
        {
            selector.ThrowIfNull(nameof(selector));

            using (_engine.BeginReadFile(_dataFile.FullName))
            {
                // The engine is IEnumerable.
                foreach (TResult item in _engine.Select(selector))
                {
                    yield return(item);
                }
            }
        }
        /// <inheritdoc />
        /// <remarks>File must contain "Thing Name" columns.</remarks>
        public List <string> ReadFile(string filename)
        {
            // Use HashSet to avoid duplicated data which can produce errors in further work.
            var result = new HashSet <string>();
            var engine = new FileHelperAsyncEngine <InputFileData>();

            using (engine.BeginReadFile(filename))
            {
                // The engine is IEnumerable.
                result.UnionWith(engine.Select(data => data.thingName));
            }
            return(result.ToList());
        }