public void Load(string fileSpec, string masterFileSpec) { FileSpec = fileSpec; MasterFileSpec = masterFileSpec; if (FileSpec != null) { _entries = new List <T>(); if (MasterFileSpec != null) { FileHelper.EnsureExists(FileSpec, MasterFileSpec); } _doc = XDocument.Load(FileSpec); InstanceName = (string)_doc.Descendants(ProfileName).First().Attribute("Name"); 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); } } ProfileListItemFactory <T> factory = new ProfileListItemFactory <T>(); foreach (XElement entry in _doc.Descendants(EntryName)) { _entries.Add(factory.Create(this, entry)); } } }
public void Load() { if (SubProfile != null) { _entries = new List <T>(); InstanceName = (string)SubProfile.Descendants(ProfileName).First().Attribute("Name"); 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); } } ProfileListItemFactory <T> factory = new ProfileListItemFactory <T>(); foreach (XElement entry in SubProfile.Descendants(EntryName)) { _entries.Add(factory.Create(this, entry)); } } }