internal override bool Handle(object raw_data) { if (HandlerCallback is null && HandlerCallbackAsync is null) { return(false); } if (raw_data is T data) { try { if (CanHandle is null || CanHandle.Invoke(data)) { try { Process(data); return(true); } catch (Exception e) { Owner.InternalLog.Error(e, $"Handler threw an exception"); InformParentOfError(e); // Errored or not, the message was handled, // so we don't want to pass it on to any other // callbacks. return(true); } } else { return(false); } }
/// <summary> /// Initializes a new instance of the <see cref="DestinationFilterHandler"/> class. /// </summary> /// <param name="canHandleDelegate">The can handle delegate.</param> /// <param name="handleDelegate">The handle delegate.</param> public DestinationFilterHandler(CanHandle canHandleDelegate, Handle handleDelegate) { this.CanHandle = canHandleDelegate; this.Handle = handleDelegate; }