/// <inheritdoc/> public async Task <TResponse> SendAsync <TMessage, TResponse>(TMessage message, CancellationToken cancellationToken) where TMessage : IMessage <TResponse> { var handler = GetHandler <IMessageHandler <TMessage, TResponse> >(); if (handler == null) { throw new InvalidOperationException(string.Format(HandlerNotFound, typeof(TMessage))); } HandlerDelegate <TMessage, TResponse> handlerDelegate = handler.HandleAsync; await handlerDelegate.Invoke(message, cancellationToken); return(await handlerDelegate.Invoke(message, cancellationToken)); }
public Response Invoke(HttpContext httpContext) { try { var status = _manager.NotifyEmail(httpContext); if (status) { if (httpContext.Items.ContainsKey("upgrade")) { _logger.LogInformation("Email notification sent for upgrade"); } else if (httpContext.Items.ContainsKey("activate")) { _logger.LogInformation("Email notification sent for activate"); } } else { return(new Response("FAILED", "Failed to send email notification")); } } catch (Exception e) { _logger.LogError($"Exception:{e.Message}"); } return(_next.Invoke(httpContext)); }
public void Run() { while (true) { string str = Console.ReadLine(); StringGenerated.Invoke(str); } }
public override Task HandleAsync(HandlerContext context, HandlerDelegate next) { if (DoHandle(context)) { SendMessage(context); } return(next.Invoke(context)); }
public IEnumerator <object> Execute(Player p, string[] words) { foreach (PlayerCheckDelegate check in PlayerChecks) { if (check.Invoke(p) == false) { return(null); } } return(Handler.Invoke(p, words)); }
/// <summary> /// 发送消息 /// </summary> /// <param name="name">消息名称</param> /// <param name="obj">消息所带参数</param> /// <returns></returns> public void postNotification(String name, Object obj) { if (!this.dict.ContainsKey(name)) { return; } List <HandlerDelegate> delegateList = this.dict[name]; int count = delegateList.Count; for (int i = 0; i < count; ++i) { HandlerDelegate handler = delegateList[i]; handler.Invoke(obj); } }
public Response Invoke(HttpContext httpContext) { try { var status = _manager.PhysicalProductPacking(httpContext); if (status) { _logger.LogInformation("Physical product packing slip generated"); } else { return(new Response("FAILED", "Faild to generate physical product packing slip")); } } catch (Exception e) { _logger.LogError($"Exception:{e.Message}"); } return(_next.Invoke(httpContext)); }
public Response Invoke(HttpContext httpContext) { try { var status = _manager.CreateDuplicateSlip(httpContext); if (status) { _logger.LogInformation("duplicate slip for royalty department created"); } else { return(new Response("FAILED", "Faild to creating duplicate slip for royalty department")); } } catch (Exception e) { _logger.LogError($"Exception:{e.Message}"); } return(_next.Invoke(httpContext)); }
public Response Invoke(HttpContext httpContext) { try { var status = _manager.AddFirstAidVideo(httpContext); if (status) { _logger.LogInformation("First ad video added"); } else { return(new Response("FAILED", "Failed to add first ad video")); } } catch (Exception e) { _logger.LogError($"Exception:{e.Message}"); } return(_next.Invoke(httpContext)); }
public Response Invoke(HttpContext httpContext) { try { var status = _manager.ProcessCommision(httpContext); if (status) { _logger.LogInformation("Processed Commision Payment"); } else { return(new Response("FAILED", "Fail to generate commission payment")); } } catch (Exception e) { _logger.LogError($"Exception:{e.Message}"); } return(_next.Invoke(httpContext)); }
public Response Invoke(HttpContext httpContext) { try { var status = _manager.ActivateMembership(httpContext); if (status) { httpContext.Items.Add("activate", true); _logger.LogInformation("Membership has been activated"); } else { return(new Response("FAILED", "Failed to activate membership")); } } catch (Exception e) { _logger.LogError($"Exception:{e.Message}"); } return(_next.Invoke(httpContext)); }
/// <summary> /// 实时监听key /// </summary> /// <returns></returns> public static void updateKey() { List <KeyCode> keys; if (keyDownDict != null) { keys = new List <KeyCode>(keyDownDict.Keys); foreach (KeyCode key in keys) { List <HandlerDelegate> list = keyDownDict[key]; if (list != null && Input.GetKeyDown(key)) { for (int i = list.Count - 1; i >= 0; --i) { HandlerDelegate handler = list[i]; handler.Invoke(); } } } } if (keyUpDict != null) { keys = new List <KeyCode>(keyUpDict.Keys); foreach (KeyCode key in keys) { List <HandlerDelegate> list = keyUpDict[key]; if (list != null && Input.GetKeyUp(key)) { for (int i = list.Count - 1; i >= 0; --i) { HandlerDelegate handler = list[i]; handler.Invoke(); } } } } }
// Update is called once per frame void Update() { //查看http请求是否有返回了 if (bIsBeginRequest) { //下载是否结束了 if (_www.isDone) { if (_www.error != null) { Debug.Log(_www.error); //回调 if (this.errorHandlerDelegate != null) { this.errorHandlerDelegate.Invoke(_www.error); } } else { if (handlerDelegate != null) { if (downloadType == DownloadType.type_bytes || downloadType == DownloadType.type_assetBundle) { //二进制 handlerDelegate.Invoke(_www.bytes); } else if (downloadType == DownloadType.type_txt || downloadType == DownloadType.type_url) { //文本 handlerDelegate.Invoke(_www.text); } } } bIsDone = true; bIsBeginRequest = false; handlerDelegate = null; } } else { //空闲时,开始下一个下载 if (bIsDone) { if (downloadList.Count > 0) { //取第一个下载项 DownloadItem downloadItem = downloadList[0]; downloadType = downloadItem.downloadType; url = downloadItem.url; handlerDelegate = downloadItem.callBack; downloadList.RemoveAt(0); if (downloadType == DownloadType.type_url) { byte[] requestParams = downloadItem.requestParams; _www = new WWW(url, requestParams);//发送请求 } else { _www = new WWW(url); } bIsBeginRequest = true; bIsDone = false; } } } }