/// <summary>
        /// Register or add subscription, based on given recieverKey, type and hook handler
        /// </summary>
        /// <param name="recieverKey">the Job id for which the handler is interested to recieve or get message notification</param>
        /// <param name="type">type of message</param>
        /// <param name="handler">the handler, is the one responsible to recieve push notification</param>
        /// <returns>Guid as key</returns>
        public Guid RegisterHook(JobId recieverKey, MessageType type, IHookHandler <JobId> handler)
        {
            if (recieverKey == default(JobId))
            {
                throw new ArgumentNullException(nameof(recieverKey));
            }
            if (handler == default(IHookHandler <JobId>))
            {
                throw new ArgumentNullException(nameof(handler));
            }

            var val = _hooks.Values.Where(h => h.Id.Equals(recieverKey) && h.Type == type && object.Equals(h.Handler, handler));

            if (val.Any())
            {
                return(val.FirstOrDefault().Key);
            }

            var id = Guid.NewGuid();

            _hooks[id] = new HookNotification()
            {
                Key = id, Id = recieverKey, Type = type, Handler = handler
            };

            return(id);
        }
Beispiel #2
0
 public void RegisterHookHandler(Type bindingType, IHookHandler hookHandler)
 {
     _registry.Add(bindingType, hookHandler);
 }