Override notification message and service

I would like my notifications to have a flag, which will inform whether they shoud be deleted on page navigation or not. Then I consume this information in Router component.
I tried do create a MyNotificationMessage class that inherits NotificationMessage and provides mentioned flag inside this class. But NotificationService in Notify method creates a new instance of NotificationMessage, so my MyNotificationMessage object is being destroyed. So I tried to create my own MyNotificationService inheriting NotificationService, that provides a new Notify method, comsumig MyNotificationMessage. But then againg I had to change RadzenNotificationMessage.razor to consume MyNotificationService instead of a default one. Unfortunately, I was not able to do this, because in * there are some properties I can't recognize like Message.SummaryContent or Message.DetailContent(Service).
Could you give me a hint on how can I implement this feature. I need to persist some messages on navigation and delete others.

Hi @Justyna,

You can try registering your service like this (to override the default one):

services.AddScoped<NotificationService, MyNotificationService>();

MyNotificationService must inherit from NotificationService.

I tried to do this, however, when I inject NotificationService in a razor comoponent, it still implements NotificationService itself and not MyNotificationService.

I checked all implementations of NotificationService in Program.cs:

foreach (var service in builder.Services.Where(s => s.ServiceType == typeof(NotificationService)))
{
	Console.WriteLine(service.ImplementationType);
}

It looks like the only implementation is MyNotificationService. But when I inject it like this:

[Inject]
public NotificationService NotificationService { get; set; }

methods consuming this service still see NotificationService class itself.

Make sure you are not registering the original NotificationService too. For example by having services.AddRadzenServices().

I'm sure that no other NotificationServices is being registerd. To be 100% sure I checked NotificationService implementations as I mentioned above and the only implementation is MyNotificationService.

Finally, I chose less clean way and just assigned my flag to NotificationMessage.Payload as I did't use it before.

Thank you for your help :slight_smile: