private dynamic GetCommand(string commandName) { commandName = commandName.Split('.').Last(); var commands = _knownTypes.GetImplementations(typeof(Command)); var commandType = commands.Single(c => c.Name.Equals(commandName, StringComparison.InvariantCultureIgnoreCase)); return(Json.Deserialize("{}", commandType)); }
public ActionResult <CommandResource> StartCommand(CommandResource commandResource) { var commandType = _knownTypes.GetImplementations(typeof(Command)) .Single(c => c.Name.Replace("Command", "") .Equals(commandResource.Name, StringComparison.InvariantCultureIgnoreCase)); Request.Body.Seek(0, SeekOrigin.Begin); using var reader = new StreamReader(Request.Body); var body = reader.ReadToEnd(); dynamic command = STJson.Deserialize(body, commandType); command.Trigger = CommandTrigger.Manual; command.SuppressMessages = !command.SendUpdatesToClient; command.SendUpdatesToClient = true; var trackedCommand = _commandQueueManager.Push(command, CommandPriority.Normal, CommandTrigger.Manual); return(Created(trackedCommand.Id)); }