public static void SaveChannel(XmlElement node, IChannel channel) { BaseChannel channelBase = (BaseChannel)channel; node.SetAttribute("type", channelBase.GetType().FullName); node.SetAttribute("name", channelBase.Name); node.SetAttribute("readOnly", channelBase.IsReadOnly.ToString()); if (channel is ComputableChannel) { ComputableChannel ch = channel as ComputableChannel; XmlElement expNode = node.OwnerDocument.CreateElement("expression"); expNode.InnerText = ch.Expression; node.AppendChild(expNode); } }
private void SaveChannels() { Interfaces.IChannel[] channels = new Interfaces.IChannel[grid.RowsCount - 1]; for (int i = 1; i < grid.RowsCount; i++) { string name = grid[i, 0].DisplayText; bool readOnly = (bool)((SourceGrid.Cells.CheckBox)grid[i, 2]).Checked; string type = null; foreach (KeyValuePair <string, string> pair in variableTypeNames) { if (grid[i, 1].DisplayText == pair.Value) { type = pair.Key; break; } } if (type == null) { continue; } if (type == typeof(ComputableChannel).FullName) { string expression = ""; if (grid.Rows[i].Tag != null) { expression = (string)grid.Rows[i].Tag; } channels[i - 1] = new ComputableChannel(name, plugin, expression); } else { channels[i - 1] = ChannelFactory.CreateChannel(type, name, readOnly, plugin); } } plugin.Channels = channels; plugin.SaveSettings(); }