protected void OnEndRequest()
 {
     //默认写法
     //if (EndRequest != null) EndRequest(this, new EventArgs());
     //新写法
     EndRequest?.Invoke(this, new EventArgs());
 }
示例#2
0
            public void SendsAndReceives()
            {
                IClient client = CreateClient();

                _runtime.ReadResponse().Returns(GetOkResponse(new EndResponse("myResult")));

                EndRequest request = new EndRequest("myPromiseId");

                client.End(request);

                _runtime.Received().WriteRequest(Arg.Is <string>(
                                                     actual => PlatformIndependentEqual(JsonConvert.SerializeObject(request), actual)
                                                     ));
                _runtime.Received().ReadResponse();
            }
        private static bool TryParseEndRequest(string line, Dictionary <string, string> stringToString, out EndRequest endRequest)
        {
            var match = EndRequestRegex.Match(line);

            if (match.Success)
            {
                endRequest = new EndRequest(
                    (HttpStatusCode)Enum.Parse(typeof(HttpStatusCode), match.Groups["StatusCode"].Value),
                    DedupeString(stringToString, match.Groups["Url"].Value.Trim()),
                    TimeSpan.FromMilliseconds(int.Parse(match.Groups["DurationMs"].Value)));
                return(true);
            }

            endRequest = null;
            return(false);
        }
 /// <summary>
 /// Triggers the EndRequest event.
 /// </summary>
 internal static void OnEndRequest(object sender, UmbracoRequestEventArgs args)
 {
     EndRequest?.Invoke(sender, args);
 }
示例#5
0
 public EndResponse End(EndRequest request)
 {
     return(Send <EndRequest, EndResponse>(request));
 }
 /// <summary>
 /// Sends a End Request to the Arduino.
 /// </summary>
 /// <param name="request">End Request</param>
 /// <returns>The End Response</returns>
 public async Task <EndResponse> SendAsync(EndRequest request)
 {
     return((EndResponse) await InternalSendAsync(request));
 }