Struct Recipient
- Namespace
- Signal.Domain.ValueObjects
- Assembly
- Signal.Domain.dll
Anything a message can be addressed to: exactly one of a PhoneNumber, an AccountId (ACI/UUID), a Username or a GroupId.
public struct Recipient : IUnion
- Implements
- Inherited Members
Remarks
A C# union: every case type converts implicitly (Recipient r = phoneNumber;), and pattern matching applies
to the contained value, with exhaustiveness checking:
var label = recipient switch
{
PhoneNumber n => $"phone {n}",
AccountId id => $"account {id}",
Username u => $"@{u}",
GroupId g => $"group {g}",
};
Address is the string sent to the REST API.
Properties
Address
The identifier in the form expected by the REST API.
public string Address { get; }
Property Value
Exceptions
- InvalidOperationException
The recipient is default (holds no value).
IsGroup
Whether this recipient is a group.
public bool IsGroup { get; }
Property Value
Methods
Parse(string)
Detects the recipient kind from its textual form. Tried in order: group id (group.…),
phone number, UUID; anything else is treated as a username.
public static Recipient Parse(string value)
Parameters
valuestringThe text to interpret.
Returns
- Recipient
The recipient.
Exceptions
- InvalidRecipientException
valueis empty or an invalid username.
ToString()
Returns Address.
public override string ToString()
Returns
TryParse(string?, out Recipient)
Tries to detect the recipient kind from its textual form (see Parse(string)).
public static bool TryParse(string? value, out Recipient recipient)