protected static Profile BaseOpenProfile(string fileName, IFileIOHandler ioHandler) { var p = new Profile { FileIOHandler = ioHandler }; var document = new XmlDocument(); document.Load(fileName); XmlNode documentElement = document.DocumentElement; p.FileName = fileName; p.ClearChannels(); if (documentElement != null) { var channelObjectsNode = documentElement.SelectNodes("ChannelObjects/*"); if (channelObjectsNode != null) { foreach (XmlNode channelObject in channelObjectsNode) { p.AddChannelObject(new Channel(channelObject), false); } } var outputNodes = documentElement.SelectSingleNode("Outputs"); if (outputNodes != null) { foreach (var outputChannel in outputNodes.InnerText.Split(',').Where(outputChannel => outputChannel.Length > 0)) { p.AddChannelOutput(Convert.ToInt32(outputChannel)); } } } p.PlugInData.LoadFromXml(documentElement); p.Groups = Group.LoadFromXml(documentElement) ?? new Dictionary <string, GroupData>(); p.IsDirty = Group.LoadFromFile(documentElement, p.Groups); if (documentElement != null) { var disabledChannelsNode = documentElement.SelectSingleNode("DisabledChannels"); if (disabledChannelsNode != null) { foreach ( var disabledChannel in disabledChannelsNode.InnerText.Split(',').Where(disabledChannel => disabledChannel != string.Empty)) { p.Channels[Convert.ToInt32(disabledChannel)].Enabled = false; } } } p.Freeze(); return(p); }