MessageHandler{TRecipient,TMessage}.cs 1.1 KB

12345678910111213141516171819
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the MIT license.
  3. // See the LICENSE file in the project root for more information.
  4. namespace CommunityToolkit.Mvvm.Messaging;
  5. /// <summary>
  6. /// A <see langword="delegate"/> used to represent actions to invoke when a message is received.
  7. /// The recipient is given as an input argument to allow message registrations to avoid creating
  8. /// closures: if an instance method on a recipient needs to be invoked it is possible to just
  9. /// cast the recipient to the right type and then access the local method from that instance.
  10. /// </summary>
  11. /// <typeparam name="TRecipient">The type of recipient for the message.</typeparam>
  12. /// <typeparam name="TMessage">The type of message to receive.</typeparam>
  13. /// <param name="recipient">The recipient that is receiving the message.</param>
  14. /// <param name="message">The message being received.</param>
  15. public delegate void MessageHandler<in TRecipient, in TMessage>(TRecipient recipient, TMessage message)
  16. where TRecipient : class
  17. where TMessage : class;