Пример #1
0
        protected virtual void ReadRecords <T>(IDictionary <int, T> storage) where T : class, new()
        {
            var fieldCache = typeof(T).GetFields().Select(x => new FieldCache <T>(x)).ToArray();

            _reader.Enumerate((row) =>
            {
                T entry = new T();
                row.GetFields(fieldCache, entry);
                lock (storage)
                    storage.Add(row.Id, entry);
            });
        }
Пример #2
0
        private void ReadRecords <T>(IDictionary <int, T> storage) where T : class, new()
        {
            var startTime = DateTime.Now;

            var fieldCache = typeof(T).GetFields().Select(x => new FieldCache <T>(x)).ToArray();

            _reader.Enumerate((row) =>
            {
                var entry = new T();
                row.GetFields(fieldCache, entry);
                lock (storage)
                    storage.Add(row.Id, entry);
            });

            var span = DateTime.Now.Subtract(startTime);

            Console.WriteLine($"{  FileName.PadRight(33) } { TimeSpan.FromTicks(span.Ticks).ToString().PadRight(28) } { storage.Count.ToString().PadRight(19) }");
        }