I have a small command line app written in C# that uses LogParser and I was looking to clean it up a little because it is all in one massive method.
I run my query and I get a LogRecordSet object:
// run the query against wowza log
LogRecordSet logSet = logQuery.Execute(sql, new W3CInputFormat());
All good. Now I want to pass logSet into a method where I will evaluate everything:
private static IEnumerable<Unprocessed> CreateRecords(LogRecordSet logRecordset)
{
for (; !logRecordset.atEnd(); logRecordset.moveNext())
{
...
}
}
And I call it like so:
var records = CreateRecords(logSet);
This compiles fine, however it just sort of ignores the CreateRecords method, just skips over it. I admittedly know very little about c# command line applications, but I would just be interested to know why this is happening, and wasn't really sure what to google.
Edit I have looked into a little more, and the problem seems to stem from the fact that my method uses
yield return log;
Can I not use yield return in this context?
private static IEnumerable<Unprocessed> CreateRecords(LogRecordSet logRecordset)
{
for (; !logRecordset.atEnd(); logRecordset.moveNext())
{
yield return ...;
}
}
Your CreateRecords()
looks ok, just make sure you start enumerating its returned IEnumerable and you'll see it'll get invoked. For example:
var foo = CreateRecords().ToArray();