Anders Bjerner
10/07/2024, 4:12 PMMyNotification
or IMyNotification
? Please answer in a ๐งต
csharp
@{
var notification = new MyNotification();
EventAggregator.Publish<IMyNotification>(notification);
<pre>Yay</pre>
}
Jemayn
10/07/2024, 7:36 PMAnders Bjerner
10/07/2024, 8:11 PMMyNotification
to be hit.
Given the code below, only MyNotificationHandler2
is hit ๐ค ๐
csharp
using Umbraco.Cms.Core.Composing;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Notifications;
namespace Umbraco13.Features.Notifications;
public class NotificationsComposer : IComposer {
public void Compose(IUmbracoBuilder builder) {
builder.AddNotificationHandler<IMyNotification, MyNotificationHandler1>();
builder.AddNotificationHandler<MyNotification, MyNotificationHandler2>();
}
}
public interface IMyNotification : INotification { }
public class MyNotification : IMyNotification { }
public class MyNotification2 : IMyNotification { }
public class MyNotificationHandler1 : INotificationHandler<IMyNotification> {
public void Handle(IMyNotification notification) {
Console.WriteLine("Hello from MyNotificationHandler1: " + notification.GetType());
}
}
public class MyNotificationHandler2 : INotificationHandler<MyNotification> {
public void Handle(MyNotification notification) {
Console.WriteLine("Hello from MyNotificationHandler2: " + notification.GetType());
}
}
Sebastiaan
10/08/2024, 8:22 AM