/// <summary> /// For default initializing /// </summary> public TestSave(QuizContext context, List <SectionView> sectionViews) { _cx = context; Id = _GenerateId(); foreach (var item in sectionViews) { var sectionSave = new SectionSave() { View = item, Answers = new Dictionary <int, XmlModels.XmlBase>() }; foreach (var test in item.Tests) { var answerName = ((IAnswerName)test.Model).GetTypeName(); var answerInstance = (XmlBase)Activator.CreateInstance(XmlBase.GetType(answerName)); sectionSave.Answers.Add(test.Question.Id, answerInstance); } Saves.Add(item.Section.Id, sectionSave); } }
public void AddSaveModifier(string saveShortName, int modifier) { if (Saves.Count == 0) { Saves.Add(saveShortName, modifier); } else { foreach (var save in Saves) { if (save.Key == saveShortName) { if (modifier == 0) { Saves.Remove(saveShortName); return; } else { Saves[saveShortName] = modifier; return; } } } Saves.Add(saveShortName, modifier); } }
public void Update(SectionView view) { if (Saves.Keys.Contains(view.SectionId)) { Saves.Remove(view.SectionId); } Saves.Add(view.SectionId, new SectionSave(view, _cx)); }
/// <summary> /// </summary> /// <param name="i"></param> /// <returns></returns> public GameState this[int i] { get { return(GameStates[i]); } //ToDo: Sort by date set { //There is no "Add new slot" it only overrides what's already present //GameState[] s = new GameState[Saves.Count]; //Saves.CopyTo(s); //s[i] = value; //Saves = new HashSet<GameState>(s); //Rewrote to override old save file with new one if (Saves.Contains(value)) { Saves.Remove(value); } if (value.TimeCreated.Ticks != new DateTime().Ticks || (value.TrainerID != 0 && value.SecretID != 0)) { Saves.Add(value); } } }