public void Load(string fileSpec, string masterFileSpec) { FileSpec = fileSpec; MasterFileSpec = masterFileSpec; if (FileSpec != null) { _entries = new Dictionary <string, T>(); if (MasterFileSpec != null) { FileHelper.EnsureExists(FileSpec, MasterFileSpec); } _doc = XDocument.Load(FileSpec); SelectedKey = string.Empty; if (_doc.Descendants("Selected").Count() > 0) { SelectedKey = (string)_doc.Descendants("Selected").First().Element(KeyName); } else { if (_doc.Descendants(EntryName).Count() > 0) { SelectedKey = (string)_doc.Descendants(EntryName).First().Attribute(KeyName); } } ProfileEntryFactory <T> factory = new ProfileEntryFactory <T>(); foreach (XElement entry in _doc.Descendants(EntryName)) { string key = (string)entry.Attribute(KeyName); _entries.Add(key, factory.Create(this, entry)); } } }
public void Load() { if (SubProfile != null) { _entries = new Dictionary <string, T>(); SelectedKey = string.Empty; if (SubProfile.Descendants("Selected").Count() > 0) { SelectedKey = (string)SubProfile.Descendants("Selected").First().Element(KeyName); } else { if (SubProfile.Descendants(EntryName).Count() > 0) { SelectedKey = (string)SubProfile.Descendants(EntryName).First().Attribute(KeyName); } } ProfileEntryFactory <T> factory = new ProfileEntryFactory <T>(); foreach (XElement entry in SubProfile.Descendants(EntryName)) { string key = (string)entry.Attribute(KeyName); _entries.Add(key, factory.Create(this, entry)); } } }