using System; using System.Collections.Generic; namespace WalletConnectSharp.Core.Events { public class EventHandlerMap { private Dictionary> mapping = new Dictionary>(); private EventHandler BeforeEventExecuted; public EventHandlerMap(EventHandler callbackBeforeExecuted) { if (callbackBeforeExecuted == null) { callbackBeforeExecuted = CallbackBeforeExecuted; } this.BeforeEventExecuted = callbackBeforeExecuted; } private void CallbackBeforeExecuted(object sender, TEventArgs e) { } public EventHandler this[string topic] { get { if (!mapping.ContainsKey(topic)) { mapping.Add(topic, BeforeEventExecuted); } return mapping[topic]; } set { if (mapping.ContainsKey(topic)) { mapping.Remove(topic); } mapping.Add(topic, value); } } public bool Contains(string topic) { return mapping.ContainsKey(topic); } } }