public bool Apply(ModbusTcpMessage message) { if (message is BasicModbusMessage) { return(Apply(message as BasicModbusMessage)); } if (message is WriteSingleMessage) { return(Apply(message as WriteSingleMessage)); } if (message is DiagnosticsMessage) { return(Apply(message as DiagnosticsMessage)); } throw new InvalidCastException("ModbusTcpMessage"); }
public bool Authorize(byte[] message) { if (Constraints == null || Constraints.Count == 0) { return(true); } ModbusTcpMessage msg = ModbusTcpMessage.Create(message); foreach (var constraint in Constraints) { if (constraint.FunctionType == msg.Function) { if (!constraint.Apply(msg)) { return(false); } } } return(true); }