public GetValueResponse <T> GetValue <T>(string key) { var response = new GetValueResponse <T>(); try { if (!string.IsNullOrWhiteSpace(key)) { var value = (T)this.cache.Get(key); if (value != null) { response.Value = value; response.Status = StatusCode.OK; } else { response.Status = StatusCode.NotFound; } } else { response.Status = StatusCode.BadRequest; } } catch (Exception ex) { response.Status = StatusCode.InternalServerError; this.exceptionHandler.HandleException(ex); } return(response); }
public CounterActor() { counter = new Counter(); Receive <IncreaseBy>((message) => counter.IncrementBy(message.Value)); Receive <GetValue>((message) => { int value = counter.GetValue(); var response = new GetValueResponse(value); message.ReplyTo.Tell(response); }); }
public void Read_Works() { var dict = new NSDictionary(); dict.Add("Request", "QueryType"); dict.Add("Result", "Success"); dict.Add("Type", "com.apple.mobile.lockdown"); var response = new GetValueResponse <string>(); response.FromDictionary(dict); Assert.Equal("QueryType", response.Request); Assert.Equal("Success", response.Result); Assert.Equal("com.apple.mobile.lockdown", response.Type); }
public GetValueResponse <T> GetValue <T>(string key) { var response = new GetValueResponse <T>(); try { if (!string.IsNullOrWhiteSpace(key)) { var cookie = this.GetCookie(key); if (cookie != null && !string.IsNullOrWhiteSpace(cookie.Value)) { try { var json = new JavaScriptSerializer(); var value = json.Deserialize <T>(cookie.Value); response.Status = StatusCode.OK; response.Value = value; } catch (ArgumentException) { response.Status = StatusCode.BadRequest; } catch (Exception ex) { response.Status = StatusCode.InternalServerError; this.exceptionHandler.HandleException(ex); } } else { response.Status = StatusCode.NotFound; } } else { response.Status = StatusCode.BadRequest; } } catch (Exception ex) { response.Status = StatusCode.InternalServerError; this.exceptionHandler.HandleException(ex); } return(response); }
public string GetValue(DebuggerApi.ValueFormat format) { GetValueResponse response = null; if (connection.InvokeRpc(() => { response = client.GetValue( new GetValueRequest { Value = grpcSbValue, Format = format.ConvertTo <Debugger.Common.ValueFormat>() }); })) { return(response.Value); } return(""); }
public void Read_ValidatesArguments() { var response = new GetValueResponse <string>(); Assert.Throws <ArgumentNullException>(() => response.FromDictionary(null)); }