/// <summary> /// Create new command response. /// </summary> /// <param name="Command">The command leading to this response.</param> /// <param name="Result">Response from the CPO on the command request.</param> /// <param name="Timeout">Timeout for this command in seconds. When the Result is not received within this timeout, the eMSP can assume that the message might never be send.</param> /// <param name="Message">Human-readable description of the result (if one can be provided), multiple languages can be provided.</param> public CommandResponse(IOCPICommand Command, CommandResponseTypes Result, TimeSpan Timeout, IEnumerable <DisplayText> Message) { this.Command = Command; this.Result = Result; this.Timeout = Timeout; this.Message = Message?.Distinct() ?? new DisplayText[0]; }
/// <summary> /// Create new command values. /// </summary> /// <param name="Command">The command.</param> /// <param name="UpstreamCommand">The optional received upstream command.</param> /// <param name="Response">The command response.</param> /// <param name="Result">The (later async) command result.</param> private CommandValues(IOCPICommand Command, IOCPICommand UpstreamCommand, CommandResponse Response = null, CommandResult?Result = null) { this.Command = Command; this.UpstreamCommand = UpstreamCommand; this.Response = Response; this.Result = Result; }
/// <summary> /// Try to parse the given JSON representation of a command response. /// </summary> /// <param name="Command">The command leading to this response.</param> /// <param name="JSON">The JSON to parse.</param> /// <param name="CustomCommandResponseParser">A delegate to parse custom command response JSON objects.</param> public static CommandResponse?TryParse(IOCPICommand Command, JObject JSON, CustomJObjectParserDelegate <CommandResponse> CustomCommandResponseParser = null) { if (TryParse(Command, JSON, out CommandResponse commandResponse, out String ErrorResponse, CustomCommandResponseParser)) { return(commandResponse); } return(default);
/// <summary> /// Parse the given text representation of a command response. /// </summary> /// <param name="Command">The command leading to this response.</param> /// <param name="Text">The text to parse.</param> /// <param name="CustomCommandResponseParser">A delegate to parse custom command response JSON objects.</param> public static CommandResponse Parse(IOCPICommand Command, String Text, CustomJObjectParserDelegate <CommandResponse> CustomCommandResponseParser = null) { if (TryParse(Command, Text, out CommandResponse commandResponse, out String ErrorResponse, CustomCommandResponseParser)) { return(commandResponse); } throw new ArgumentException("The given text representation of a command response is invalid: " + ErrorResponse, nameof(Text)); }
/// <summary> /// Create new command values. /// </summary> /// <param name="UpstreamCommand">The received upstream command.</param> public static CommandValues FromUpstreamCommand(IOCPICommand UpstreamCommand) => new CommandValues(null, UpstreamCommand);
/// <summary> /// Create new command values. /// </summary> /// <param name="Command">The command.</param> public static CommandValues FromCommand(IOCPICommand Command) => new CommandValues(Command, null);