public static Settings FromByteArray(byte[] data) { Settings res = null; if (data != null) { using (MemoryStream xmlStream = new MemoryStream(data)) { XmlReaderSettings ss = new XmlReaderSettings(); ss.IgnoreWhitespace = true; ss.IgnoreComments = true; using (XmlReader reader = XmlReader.Create(xmlStream, ss)) { while (!reader.EOF) { reader.Read(); if (reader.NodeType == XmlNodeType.Element && reader.Name == "Settings") { res = new Settings(); //if (!Utils.StringIsNullOrEmpty(reader.GetAttribute("UseWiFi"))) // res.UseWiFi = reader.GetAttribute("UseWiFi") == bool.TrueString; if (!Utils.StringIsNullOrEmpty(reader.GetAttribute("WiFiSSID"))) res.WiFiSSID = reader.GetAttribute("WiFiSSID"); if (!Utils.StringIsNullOrEmpty(reader.GetAttribute("WiFiPassword"))) res.WiFiPassword = reader.GetAttribute("WiFiPassword"); //if (!Utils.StringIsNullOrEmpty(reader.GetAttribute("MainBridgeCurrentThreshould"))) // res.MainBridgeCurrentThreshould = int.Parse(reader.GetAttribute("MainBridgeCurrentThreshould")); //if (!Utils.StringIsNullOrEmpty(reader.GetAttribute("ProgBridgeCurrentThreshould"))) // res.ProgBridgeCurrentThreshould = int.Parse(reader.GetAttribute("ProgBridgeCurrentThreshould")); //if (!Utils.StringIsNullOrEmpty(reader.GetAttribute("BroadcastBoostersCurrent"))) // res.BroadcastBoostersCurrent = reader.GetAttribute("BroadcastBoostersCurrent") == bool.TrueString; } } } } } return res; }
public static Settings LoadFromFlash(uint id) { Settings res = new Settings(); object data = FlashManager.LoadFromFlash(typeof(string), 0); if (data != null) res = Settings.FromXml((string)data); return res; }
public static Settings LoadFromSD(string root) { Settings res = new Settings(); byte[] data = DriveManager.LoadFromSD(root + fileName); if (data == null) res.SaveToSD(root); else res = Settings.FromByteArray(data); return res; }
private void InitSettings() { //if (sdCard.IsCardInserted) //{ // sdCard.MountSDCard(); // Thread.Sleep(500); // settings = Settings.LoadFromSD(sdCard.GetStorageDevice().RootDirectory); //} //settings = Settings.LoadFromFlash(0); settings = new Settings(); }