protected void AppendRow(DataView view, Type recType, MappedRecord model) { modelTables.Single(kvp => kvp.Key == model.GetType()).Value.ForEach(mt => mt.BeginProgrammaticUpdate()); DataRow row = NewRow(view, recType, model); view.Table.Rows.Add(row); AddRecordToCollection(model); modelTables.Single(kvp => kvp.Key == recType).Value.ForEach(mt => mt.EndProgrammaticUpdate()); }
public void Replace(MappedRecord oldEntity, MappedRecord withEntity) { var oldEntityType = oldEntity.GetType(); var mappedEntities = mappedRecords[oldEntityType]; int idx = mappedEntities.Cast <MappedRecord>().IndexOf(e => e.Row == oldEntity.Row); if (idx != -1) { mappedEntities[idx] = (IEntity)withEntity; } var tables = modelTables[oldEntityType]; tables.ForEach(mt => mt.Replace((IEntity)oldEntity, (IEntity)withEntity)); }
protected void AddRecordToCollection(MappedRecord record) { Assert.That(mappedRecords.ContainsKey(record.GetType()), "Model Manager does not know about " + record.GetType().Name + ".\r\nCreate an instance of ModuleMgr with this record collection."); mappedRecords[record.GetType()].Add((IEntity)record); }