Say hypothetically you had a reader which did something like this...

//testing reader, automatically parses strings and converts to the custom type via attributes!
using ( FlatFileReader<MyCustomClass> reader = new FlatFileReader<MyCustomClass>(config) ) {
    MyCustomClass custom;
    while ( (custom = reader.ReadLine()) != null ) {
        Console.WriteLine(custom.ToString());
    }
}

Would this actually be useful in not just flat files, but CSV, etc, etc? I am just having some second thoughts about this program, as to whether it would actually be useful to people. There's not really any technical problems with this, I just want some opinions.

Certainly being able to parse file input into something meaningful is always useful. To make it even more generic, why not use a Stream input instead? That way you can handle any input type (including files, via FileStream) so long as the format is what you expect.

commented: Good thoughts! +3

Right, good point. The only reason I am using a config object here is that it is a fixed width file parser. I am probably not using the correct vocabulary in some of the program, but I am essentially passing in a config object which contains a file path, as-well as an array of classes which represent the characteristics of each field, widths, alignment, and field name in case somebody actually wants to print a column header in the file (usually you don't but I have seen some CSV's with this user friendly feature). The idea is I can serialize the configuration object, and reload, etc. The objective in my mind for this program was to make it so that it is useful to different companies/people who may not all have the same fixed width formats.

I could probably think of making a few overloads so I could pass streams to this object, but I would have to think about this to make sure the config object is still useful. Perhaps I should just remove the config object's path/name variable?

This tip I got from deceptikon here.

commented: Yes, TextReaders are cool, I was just wondering if typed readers would be useful, returns a custom object. +3
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.