/// <summary> /// Save the scenario info in the Preferences server /// </summary> /// <param name="popScenario"></param> private void SaveScenario(IScenarioPrefs scenarioPrefs) { // Preferences must be active if (Properties.Settings.Default.ConnectionStringUserPreferences == "") { return; } SavePreferencesToFile(); }
private IScenarioPrefs CreatePreference(XmlNode scenarioNode) { if (scenarioNode.ChildNodes.Count == 0) { return(null); } string type = scenarioNode.Attributes["Type"].Value; string version = scenarioNode.Attributes["Version"].Value; string name = scenarioNode.Attributes["Name"].Value; IScenarioPrefs pref = null; switch (type) { case "INS": { pref = new InstancePrefs(name); pref.Deserialize(scenarioNode.ChildNodes[0], version); break; } case "POP": { pref = new PopulationPrefs(name, 0); pref.Deserialize(scenarioNode.ChildNodes[0], version); break; } case "FORM": { pref = new FormPrefs(name); pref.Deserialize(scenarioNode.ChildNodes[0], version); break; } } return(pref); }
/// <summary> /// Reads the user preferences from a existing XML file /// </summary> private void ReadPreferencesFromFile() { try { string fileName = GetPreferencesFileName(true); if (fileName == "") { return; } XmlDocument lXMLDocument = new XmlDocument(); lXMLDocument.Load(fileName); // Get main node XmlNodeList lMainNodeList = lXMLDocument.GetElementsByTagName("Preferences"); if (lMainNodeList.Count != 1) { return; } // Preferences node. XmlNode lPreferencesNode = lMainNodeList[0]; // Get all Scenario nodes XmlNodeList lScenarioNodes = lPreferencesNode.SelectNodes("Scenario"); IScenarioPrefs pref = null; foreach (XmlNode lScenarioNode in lScenarioNodes) { pref = CreatePreference(lScenarioNode); if (pref != null) { mScenarioPreferences.Add(pref); } } } catch { } }
/// <summary> /// Save the scenario info in the Preferences server /// </summary> /// <param name="popScenario"></param> private void SaveScenario(IScenarioPrefs scenarioPrefs) { // Preferences must be active if (Properties.Settings.Default.ConnectionStringUserPreferences == "") return; SavePreferencesToFile(); }