Exemple #1
0
        private void readTargetFromLine(FlatFileRequest <T> request, FlatFileRequestData data, string line, BindingContext context)
        {
            data.ReadLine(line);

            var target = request.Finder(data);

            _binder.Bind(typeof(T), target, context);

            request.Callback(target);
        }
        private void readTargetFromLine(FlatFileRequest <T> request, FlatFileValues data, string line, BindingContext context)
        {
            data.ReadLine(line);

            var target = request.Finder(new RequestData(new FlatValueSource(data)));

            _resolver.BindProperties(target, context);

            request.Callback(target);
        }
Exemple #3
0
        public void ReadFile(FlatFileRequest <T> request)
        {
            using (var stream = new FileStream(request.Filename, FileMode.Open, FileAccess.Read))
            {
                var reader  = new StreamReader(stream, request.Encoding);
                var headers = reader.ReadLine();
                if (headers.IsEmpty())
                {
                    return;
                }

                processData(request, reader, headers);
            }
        }
Exemple #4
0
        private void processData(FlatFileRequest <T> request, StreamReader reader, string headers)
        {
            var data = new FlatFileRequestData(request.Concatenator, headers);

            _aliases.Each((header, alias) => data.Alias(header, alias));

            var context = new BindingContext(data, _services);

            string line;

            while ((line = reader.ReadLine()) != null)
            {
                readTargetFromLine(request, data, line, context);
            }
        }