public WorkModule(ICommandDispatcher dispatcher, ICommandDeserializer deserializer) { Post["/work"] = r => { object command; try { var reader = new StreamReader(Request.Body); string str = reader.ReadToEnd(); command = deserializer.Deserialize(str); } catch (InvalidCommandObjectException) { return new Response().WithStatusCode(HttpStatusCode.BadRequest); } try { dispatcher.Dispatch(command); return new Response().WithStatusCode(HttpStatusCode.OK); } catch (NoAvailableHandlerException) { return new Response().WithStatusCode(HttpStatusCode.NotImplemented); } }; }
public WorkModule(ICommandDispatcher dispatcher, ICommandDeserializer deserializer) { Post["/work"] = r => { IUserSession userSession = this.UserSession(); object command; try { var reader = new StreamReader(Request.Body); string str = reader.ReadToEnd(); command = deserializer.Deserialize(str); } catch (InvalidCommandObjectException) { throw new BadRequestException("Invalid command object."); } try { dispatcher.Dispatch(userSession, command); return null; } catch (NoAvailableHandlerException) { throw new NotImplementedException("The command does not have a handler."); } }; }
public RestSharpIronMqClientAdapter(ICommandSerializer serializer, ICommandDeserializer deserializer, ICommandDispatcher commandDispatcher, IIronMqSettings settings) { _serializer = serializer; _deserializer = deserializer; _commandDispatcher = commandDispatcher; _settings = settings; string ironMqUrl = _settings.IronMqUrl; _client = new RestClient(string.Format(ironMqUrl + "/1/projects/{0}", _settings.ProjectId)); _maxCommandsToProcessEachPoll = Config.GetMaxCommandsToProcessPerPoll(); }
/// <summary> /// Instructs to use supplied <see cref="ICommandDeserializer"/> instead of default implementation for the purpose of deserializing command arguments. /// </summary> /// <param name="deserializer"></param> /// <returns></returns> public CLIFlow UseDeserializer(ICommandDeserializer deserializer) { _deserializer = deserializer ?? throw new ArgumentNullException(nameof(deserializer)); return(this); }
internal CLIFlow() { _deserializer = new LogicalCommandDeserializer(); _fallbackFunc = (error) => { }; }
public CommandHandler(ICommandDeserializer deserializer) { _deserializer = deserializer; }
public RegexArgumentDeserializerTests() { Deserializer = new LogicalCommandDeserializer(); }