private ICommand GetCommand(XElement element, object channel) { ICommand command = null; string commandType = GetAttribute(element, "Type"); string commandName = GetAttribute(element, "Name"); if (commandType == "ByteArrayCommand") { if (!string.IsNullOrEmpty(element.Value.Trim())) { command = new ByteArrayCommand(commandName, (IChannel <byte[]>)channel, HexStringToByteArray(element.Value.Trim().Replace(" ", ""))); } else { throw new ElementValueNotFoundException("Command value not found."); } } else if (commandType == "StringCommand") { if (!string.IsNullOrEmpty(element.Value.Trim())) { command = new StringCommand(commandName, (IChannel <string>)channel, element.Value.Trim()); } else { throw new ElementValueNotFoundException("Command value not found."); } } else { throw new UnknownElementException("Unknown command type:" + commandType); } _adapterObjects[_currentAdapterName].Add(command.Name, command); return(command); }
private ICommand GetCommand(XElement element, object channel) { ICommand command = null; string commandType = GetAttribute(element, "Type"); string commandName = GetAttribute(element, "Name"); if (commandType == "ByteArrayCommand") { if (!string.IsNullOrEmpty(element.Value.Trim())) { command = new ByteArrayCommand(commandName, (IChannel<byte[]>)channel, HexStringToByteArray(element.Value.Trim().Replace(" ", ""))); } else { throw new ElementValueNotFoundException("Command value not found."); } } else if (commandType == "StringCommand") { if (!string.IsNullOrEmpty(element.Value.Trim())) { command = new StringCommand(commandName, (IChannel<string>)channel, element.Value.Trim()); } else { throw new ElementValueNotFoundException("Command value not found."); } } else { throw new UnknownElementException("Unknown command type:" + commandType); } _adapterObjects[_currentAdapterName].Add(command.Name, command); return command; }