| 12345678910111213141516171819202122232425262728 | using System;using System.Collections.Generic;using System.Text;namespace InABox.Core.Notifications{    public class Notifications    {        private Dictionary<Type, INotificationHandler> Handlers = new Dictionary<Type, INotificationHandler>();        public void AddHandler<TNotification>(NotificationHandler<TNotification> handler)        {            Handlers[typeof(TNotification)] = handler;        }        public void AddHandler<TNotification>(NotificationHandler<TNotification>.ReceiveEvent receive)        {            Handlers[typeof(TNotification)] = new NotificationHandler<TNotification>(receive);        }        public void Notify(Type type, object? notification)        {            if (Handlers.TryGetValue(type, out var handler))            {                handler.Receive(notification);            }        }    }}
 |