/// <summary> /// Process a query. /// </summary> /// <typeparam name="TResult">The type of result</typeparam> /// <param name="queryName">The name of the query</param> /// <param name="json">The JSON representation of the query</param> /// <returns>The result of the query</returns> public async Task <TResult> ProcessAsync <TResult>(string queryName, JObject json) { var queryType = _typeCollection.GetType(queryName); if (queryType == null) { throw new QueryProcessorException($"The query type '{queryName}' could not be found"); } var query = json.SafeToObject(queryType); if (query == null) { throw new QueryProcessorException("The json could not be converted to an object"); } return(await ProcessAsync((dynamic)query)); }
private Type GetQueryType(string queryName) { var queryType = _typeCollection.GetType(queryName); if (queryType == null) { throw new QueryProcessorException($"The query type '{queryName}' could not be found"); } return(queryType); }
public async Task ProcessAsync(string commandName, JObject json) { var commandType = _typeCollection.GetType(commandName); if (commandType == null) { throw new CommandProcessorException($"The command type '{commandName}' could not be found"); } var command = json.SafeToObject(commandType); if (command == null) { throw new CommandProcessorException("The json could not be converted to an object"); } await ProcessAsync((dynamic)command); }
private object GetCommand(string commandName, JObject json) { var commandType = _typeCollection.GetType(commandName); if (commandType == null) { throw new CommandProcessorException($"The command type '{commandName}' could not be found"); } var command = json.SafeToObject(commandType); if (command == null) { throw new CommandProcessorException("The json could not be converted to an object"); } return(command); }
/// <summary> /// Returns the type of query. /// </summary> /// <param name="queryName">The name of the query</param> /// <returns>The query type</returns> public Type GetQueryType(string queryName) { return(_typeCollection.GetType(queryName)); }
/// <summary> /// Returns the type of command. /// </summary> /// <param name="commandName">The name of the command</param> /// <returns>The command type</returns> public Type GetCommandType(string commandName) { return(_typeCollection.GetType(commandName)); }