Instead of a simple switch statement ...
This is Luke's kind of code. I might be catching the virus ...
abstract class QIFParserBase {
public enum LoadOptions {
All,
Prices,
Securities,
Transactions
}
static readonly Dictionary<LoadOptions, Action<QIFParserBase, string[]>> parseFuncs =
new Dictionary<LoadOptions, Action<QIFParserBase, string[]>> {
{LoadOptions.All, (q,c) => q.ParseAll(c)},
{LoadOptions.Prices, (q,c) => q.ParsePricesBlocks(c)},
{LoadOptions.Securities, (q,c) => q.ParseSecurityBlocks(c)},
{LoadOptions.Transactions, (q,c) => q.ParseTransactionBlocks(c)}
};
public QIFParserBase(string fileName, LoadOptions opt) {
string content = File.ReadAllText(fileName);
string[] blocks = content.Split(new string[] { "!Type:", "!Option:" },
StringSplitOptions.RemoveEmptyEntries);
parseFuncs[opt](this,blocks);
}