public override void LoadParameters(XElement xml) { base.LoadParameters(xml); if (string.IsNullOrEmpty(PortType)) throw new Exception("InputPortType is null"); if (PortType == "Lan") { Port = new LanPortInterface(); } Port.LoadParameters(xml.Element("Port")); Port.ReceiveDataDelegate = delegate(string data) { if (ReceiveDataDelegate != null) ReceiveDataDelegate(data); }; Port.OnConnected += delegate(object sender, EventArgs e) { OnConnected(sender, e); }; Port.OnDiconnected += delegate(object sender, FAGenericEventArgs<string> e) { OnDiconnected(sender, e); }; }
public override void LoadParameters(System.Xml.Linq.XElement xml) { base.LoadParameters(xml); if (InputPortType == null) throw new Exception("InputPortType is null"); if (OutputPortType == null) throw new Exception("InputPortType is null"); if (InputPortType.Trim() == "Serial") { InputPort = new SerialPortInterface(); } else if (InputPortType.Trim() == "Lan") { InputPort = new LanPortInterface(); } else throw new Exception(Name + ", Wrong InputPortType :" + InputPortType); InputPort.LoadParameters(xml.Element("InputPort")); if (InputPortType == OutputPortType) { OutputPort = InputPort; return; } if (OutputPortType.Trim() == "Serial") { OutputPort = new SerialPortInterface(); } else if (OutputPortType.Trim() == "Lan") { OutputPort = new LanPortInterface(); } else throw new Exception(Name + ", Wrong OutputPortType :" + OutputPortType); OutputPort.LoadParameters(xml.Element("OutputPort")); }