public static DeviceCollection ParseConfigFile(string xml) { var deviceList = new DeviceCollection(); if (string.IsNullOrEmpty(xml)) { return(deviceList); } var doc = XDocument.Parse(xml); var ns = doc.Root.Name.Namespace; var header = doc.Descendants(ns + "Header").FirstOrDefault(); if (header != null) { deviceList.CreateTime = (DateTime)header.Attribute("creationTime"); deviceList.AgentInformation = AgentInformation.FromXml(header); } var devices = from d in doc.Descendants(ns + NodeNames.Device) select d; foreach (var deviceNode in devices) { deviceList.Add(Device.FromXElement <Device>(ns, deviceNode)); } return(deviceList); }
public DeviceCollection Probe() { var xml = GetProbeXml(); #if IPHONE DeviceCollection devices = ConfigParser.ParseConfigFile(xml); return(devices); #else var devices = ConfigParser.ParseConfigFile(xml); return(devices); #endif }
public static Device GetDeviceContainingDataItem(this DeviceCollection c, string dataItemID) { return((from d in c where d.DataItems.Find(i => i.ID == dataItemID).Count() > 0 select d).FirstOrDefault()); }