private static async void InventoryService_RequestReceived(AppServiceConnection sender, AppServiceRequestReceivedEventArgs args) { BaseCommandResult result = null; var command = MessagingUtils.UnpackCommand <BaseCommand>(args.Request.Message); if (command is CheckCommand) { var checkResult = new CheckResult(); SysInfo.Fill(checkResult); SpeculationControl.Fill(checkResult); result = checkResult; } else { result = new ErrorResult(); } await args.Request.SendResponseAsync(MessagingUtils.PackResult <ValueSet>(result)); // close app after each command m_appServiceExit.Set(); }
protected virtual async Task <ICommandResult <T> > GetResultAsync <T>(HttpResponseMessage response) { T entity = default(T); try { entity = await response.Content.ReadAsAsync <T>(); var result = new BaseCommandResult <T>(response, entity); return(result); } catch { string error = string.Empty; using (var stream = new StreamReader(await response.Content.ReadAsStreamAsync())) { stream.BaseStream.Position = 0; error = stream.ReadToEnd(); } var errorResult = new BaseCommandResult <T> ( response: response, code: (int)response.StatusCode, error: error ); return(errorResult); } }
/// <summary> /// Constructor. Protected because we don't want anyone creating a base class instance. /// </summary> protected BaseCommand() { DG200FileLogger.Log("BaseCommand constructor.", 3); this._session = null; this._currentResult = null; this._serialConnection = null; }
public static TCR PackResult <TCR>(BaseCommandResult result) where TCR : IDictionary <string, object> { return(PackMessage <TCR>(RESULT, result)); }
public void HandlerShouldPass_OnCreateUser() { _result = (BaseCommandResult)_handler.Handle(_validCommand); Assert.AreEqual(_result.Success, true); }
public void HandlerShouldFail_OnCreateUser() { _result = (BaseCommandResult)_handler.Handle(_invalidCommand); Assert.AreEqual(_result.Success, false); }