public void AddSaver(IDataSaverBase saver) { if (FunctionDB.ContainsKey(saver.SavingType)) { throw new LPGException("Saver was already registered for type " + saver.SavingType.FullName); } FunctionDB.Add(saver.SavingType, saver); }
public void Save(HouseholdKey key, object o) { Type t = o.GetType(); if (!FunctionDB.ContainsKey(t)) { throw new LPGException("Forgotten Logger for " + t.FullName); } IDataSaverBase dsb = FunctionDB[t]; dsb.Run(key, o); }
public void SaveList(List <IHouseholdKey> objectsWithKey) { if (objectsWithKey.Count == 0) { Logger.Error("While trying to save some results, not a single object was contained in the list"); return; } Type t = objectsWithKey[0].GetType(); if (!FunctionDB.ContainsKey(t)) { throw new LPGException("Forgotten Logger for " + t.FullName); } var keys = objectsWithKey.Select(x => x.HouseholdKey).Distinct().ToList(); foreach (HouseholdKey householdKey in keys) { var filtered = objectsWithKey.Where(x => x.HouseholdKey == householdKey).ToList(); IDataSaverBase dsb = FunctionDB[t]; dsb.Run(householdKey, filtered); } }