Class RequestMessage<T>
- Namespace
- CommunityToolkit.Mvvm.Messaging.Messages
- Assembly
- CommunityToolkit.Mvvm.dll
A class for request messages, which can either be used directly or through derived classes.
public class RequestMessage<T>
Type Parameters
TThe type of request to make.
- Inheritance
-
RequestMessage<T>
- Inherited Members
Constructors
RequestMessage()
public RequestMessage()
Properties
HasReceivedResponse
Gets a value indicating whether a response has already been assigned to this instance.
public bool HasReceivedResponse { get; }
Property Value
Response
Gets the message response.
public T Response { get; }
Property Value
- T
Exceptions
- InvalidOperationException
Thrown when HasReceivedResponse is false.
Methods
Reply(T)
Replies to the current request message.
public void Reply(T response)
Parameters
responseTThe response to use to reply to the request message.
Exceptions
- InvalidOperationException
Thrown if Response has already been set.
Operators
implicit operator T(RequestMessage<T>)
Implicitly gets the response from a given RequestMessage<T> instance.
public static implicit operator T(RequestMessage<T> message)
Parameters
messageRequestMessage<T>The input RequestMessage<T> instance.
Returns
- T
Exceptions
- ArgumentNullException
Thrown if
messageis null.- InvalidOperationException
Thrown when HasReceivedResponse is false.