/** * Saves the object specified by the Dictionary parameter. * This function will always * check if an object with the name exists before it adds it. If it does * it just won't add the object. Also will check to make sure there is * still room (could become outdated functionality). */ public void SaveAll() { string toWriteToFile = (string)Json.Serialize(saveContents); saveLoader.Write(toWriteToFile); saveContents = ((Dictionary <string, System.Object>)Json.Deserialize(saveLoader.Read())); }
public Dictionary <string, System.Object> LoadOne() { string toLoadJson = saves.Read(); Dictionary <string, System.Object> savedDictionary = (Dictionary <string, System.Object>)Json.Deserialize(toLoadJson); string toCompareJson = defaults.ReadDefault(); Dictionary <string, System.Object> toCompare = (Dictionary <string, System.Object>)Json.Deserialize(toCompareJson); return(savedDictionary); }
public void SaveOne(string name, Dictionary <string, System.Object> toSave) { string toLoadJson = saves.Read(); if (toLoadJson.Equals("")) { Dictionary <string, System.Object> toAddAdditionalTo = new Dictionary <string, object>(); toAddAdditionalTo.Add(name, toSave); saves.Write((string)Json.Serialize(toAddAdditionalTo)); } else { Dictionary <string, System.Object> toAddAdditionalTo = ((Dictionary <string, System.Object>)Json.Deserialize(toLoadJson)); toAddAdditionalTo.Add(name, toSave); string toWriteToFile = (string)Json.Serialize(toAddAdditionalTo); saves.Write(toWriteToFile); } }
/* * Simple constructor. */ public MarineDAO(iFileLoader saveLoader, iFileLoader defaultLoader) { this.saveLoader = saveLoader; this.defaultLoader = defaultLoader; string toLoadJson = saveLoader.Read(); //.Read() will return ERROR if the file does not exist. If this is the case //then we will wait for saveContents to get set in the BuildFilePath() function which //is predictably called before any DAO's are used. In the other case we are using the //save files which DO exist and so saveContents will get set here. if (!toLoadJson.Equals("ERROR")) { saveContents = ((Dictionary <string, System.Object>)Json.Deserialize(toLoadJson)); } string toLoadDef = defaultLoader.ReadDefault(); if (!toLoadDef.Equals("ERROR")) { defaultContent = ((Dictionary <string, System.Object>)Json.Deserialize(toLoadDef)); } }
/* * Load the entire list of logs from log file. */ public string Load() { string toReturn = directory.Read(); return(toReturn); }