/// <inheritdoc />
        public bool Bind <TBindType>(IMessageHandler <TMessageType, TMessageContext> target)
            where TBindType : TMessageType
        {
            using (SyncObj.WriterLock())
            {
                HandlerRouteMap[typeof(TBindType)] = target;
            }

            return(true);
        }
        /// <inheritdoc />
        public async Task <bool> HandleMessageAsync(TMessageContext context, TMessageType message, CancellationToken token = default)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }

            IMessageHandler <TMessageType, TMessageContext> handler;

            using (await SyncObj.ReaderLockAsync())
            {
                //TODO: Should we log?
                if (!HandlerRouteMap.ContainsKey(message.GetType()))
                {
                    handler = HandlerRouteMap[typeof(TMessageType)];
                }
                else
                {
                    //Route to a handler that matches the message type.
                    handler = HandlerRouteMap[message.GetType()];
                }
            }

            //Possible there is no bound handler for this message type.
            if (handler == null)
            {
                return(false);
            }

            //We want to call this OUTSIDE the lock, no reason to hold the lock for this
            await handler.HandleMessageAsync(context, message, token);

            return(true);
        }