public ConfigHelper(string path) { Logger.InfoFormat("Inizializzazione ConfigHelper da {0}", path); _cachedValues = new Map(); var cfg = new Xml(path); using (cfg.Buffer()) { foreach (string section in cfg.GetSectionNames()) { var map = new Map(); _cachedValues[section] = map; foreach (string key in cfg.GetEntryNames(section)) map[key] = cfg.GetValue(section, key); } _cachedValues["ModelloDatabase"] = cfg.GetValue("Settings", "ModelloDatabase", ServerFacade.SqlServer); _cachedValues["StringaDiConnessione"] = Crypto.FastDecrypt(cfg.GetValue("Settings", "StringaDiConnessione", Crypto.FastEncrypt(""))); _cachedValues["MainTimer"] = cfg.GetValue("Settings", "MainTimer", 60); } }
private List<Sheet> ImportSheet(String filename) { List<Sheet> sheets = new List<Sheet>(); Xml ImportFile = new Xml(filename); try { ImportFile.RootName = "notesheet"; string[] sheetsecs = ImportFile.GetSectionNames(); String name, content; foreach (String sheetname in sheetsecs) { name = ImportFile.GetValue(sheetname, "name", "[Noname]"); content = ImportFile.GetValue(sheetname, "content", ""); sheets.Add(new Sheet(name, content)); } } finally { } return sheets; }
public bool LoadFromFile(String fileName,bool merge) { if (!File.Exists(fileName)) return false; Xml watchList = new Xml(fileName); watchList.RootName = "watchlist"; String[] sections = watchList.GetSectionNames(); if (sections.Length == 0) return false; if(!merge) Clear(); Array.Sort(sections); String sectionName, name, addressString; int sizeInt; WatchDataSize dataSize; UInt32[] address; for (int i = 0; i < sections.Length; i++) { sectionName = sections[i]; if(!watchList.HasEntry(sections[i],"name")) continue; if(!watchList.HasEntry(sections[i],"address")) continue; name = watchList.GetValue(sections[i], "name", "Name"); addressString = watchList.GetValue(sections[i], "address", "80000000"); if (!TryStrToAddressList(addressString, out address)) continue; sizeInt = watchList.GetValue(sections[i], "size", 2); switch (sizeInt) { case 0: dataSize = WatchDataSize.Bit8; break; case 1: dataSize = WatchDataSize.Bit16; break; case 3: dataSize = WatchDataSize.SingleFp; break; default: dataSize = WatchDataSize.Bit32; break; } AddWatch(name, address, dataSize); } return true; }