MvvmLightMessageSource

Nov 30, 2011 at 11:28 PM

This may be useful:

namespace Fox.Silverlight.Models
{
    /// <summary>
    /// Enumerates the Sources of MVVM Light Messages
    /// </summary>
    public enum MvvmLightMessageSource
    {
        Unspecified,
        ApplicationCore,
        Model,
        View,
        ViewModel,
        ViewModelLocator
    }
}
The idea here is that I can avoid specifying specific CLR types when sending messages and embrace filtering out messages based on named architectural parts of the application.
The following logic gate in a message receiver illustrates:
Messenger.Default.Register<PaginationViewMessage>(this,
    new Action<PaginationViewMessage>(
        (message) =>
        {
            if (message.Source != MvvmLightMessageSource.View) return;

            this.PaginationViewCurrentPage = message.CurrentPage;
            this.PaginationViewPageSize = message.PageSize;
            this.RentalRequisitionSearchItem = string.Empty;
            this.RentalRequisitionSearchWord = string.Empty;
            this.SetDefaultRequisitionStatus();
            this.DoRentalRequisitionSearch();
        }));