Skip to content

Instantly share code, notes, and snippets.

@panesofglass
Created October 24, 2009 18:14
Show Gist options
  • Save panesofglass/217651 to your computer and use it in GitHub Desktop.
Save panesofglass/217651 to your computer and use it in GitHub Desktop.
public abstract class DetailLoader<T> : IDetailLoader<T>
{
public virtual void Load(string importPath, Action<T> addToBatch)
{
var spreadsheet = SpreadsheetDocument.Load(importPath);
var rows = spreadsheet.Rows();
var details = GetDetailItems(rows);
foreach (var detail in details)
addToBatch(detail);
}
public virtual IEnumerable<T> GetDetailItems(IEnumerable<Row> rows)
{
foreach (var row in rows)
{
var detail = GetDetailItemFrom(row);
yield return detail;
}
}
public abstract T GetDetailItemFrom(Row row);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment