private IList <ConfigSection> ReadConfig() { var sections = new List <ConfigSection>(); ConfigSection currentSection = null; int rowCount = mySheet.GetRowCount(); for (int row = 1; row <= rowCount; ++row) { if (IsEmptyRow(row)) { continue; } var sectionName = TryGetSectionTitle(row); if (sectionName != null) { currentSection = GetOrCreateSection(sections, sectionName); } else { if (currentSection == null) { // found properties outside any section // -> lets create a placeholder for those properties currentSection = GetOrCreateSection(sections, UnassignedSectionName); } currentSection.Properties.Add(ReadProperty(row)); } } return(sections); }