public IRestEndpoint AggregateNext(string fullResourcePath) { if (string.IsNullOrEmpty(fullResourcePath)) { return(_startEndpoint); } IRestEndpoint endpoint = _startEndpoint; string[] dirs = fullResourcePath.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries); foreach (string dir in dirs) { var path = new AggregatorNextPath(dir, _namingConventionSwitcher); try { endpoint = endpoint.Next(path); } catch (Exception ex) { throw new NextEndpointErrorException(path, ex); } if (endpoint == null) { throw new NextEndpointNotFoundException(path); } } return(endpoint); }
public async Task FieldSelector_ManualNext_CorrectName() { var endpointContext = new TestEndpointContext(); var testQuery = new TestCollectionQuery { SelectFields = new[] { "Name" } }; EngineRestCollection <Artist> artistsCollection = IntegratedRestDirectory.GetArtistCollection(endpointContext.Request); IRestEndpoint endpoint = endpointContext.Services.EndpointResolver.GetFromResource(endpointContext, artistsCollection); endpoint = endpoint.Next(new AggregatorNextPath("123", endpointContext.Services.NameSwitcher)); var response = (ItemBody)(await endpoint.GetAsync(testQuery)); Assert.Equal(response.Item["Name"], TestRepositories.ArtistName); }
private async Task <object> ExecuteWithRequeryAsync(IRequestReader reader, ResponseBuilder response) { object returnValue = await _executor.ExecuteAsync(reader, response); IRestEndpoint endpoint = _executor.Endpoint; if (returnValue is AcknowledgmentFeedback ackFeedback && ackFeedback.Acknowledgment is CreatedItemAcknowledgment created) { endpoint = endpoint.Next(new RawNextPath(created.NewIdentifier.ToString())); Debug.Assert(endpoint != null); } ResourceBody resourceBody = await endpoint.GetAsync(reader.GetQuery()); response.AddResource(resourceBody); return(returnValue); }