protected QueryParameterService(IResourceGraph resourceGraph, ICurrentRequest currentRequest) { _mainRequestResource = currentRequest.GetRequestResource(); _resourceGraph = resourceGraph; _requestResource = currentRequest.RequestRelationship != null ? resourceGraph.GetResourceContext(currentRequest.RequestRelationship.RightType) : _mainRequestResource; }
private Type GetDocumentPrimaryType() { if (_currentRequest.RequestRelationship != null && !_currentRequest.IsRelationshipPath) { return(_currentRequest.RequestRelationship.RightType); } return(_currentRequest.GetRequestResource()?.ResourceType); }
/// <inheritdoc/> public TopLevelLinks GetTopLevelLinks() { ResourceContext resourceContext = _currentRequest.GetRequestResource(); TopLevelLinks topLevelLinks = null; if (ShouldAddTopLevelLink(resourceContext, Link.Self)) { topLevelLinks = new TopLevelLinks { Self = GetSelfTopLevelLink(resourceContext) }; } if (ShouldAddTopLevelLink(resourceContext, Link.Paging) && _pageService.CanPaginate) { SetPageLinks(resourceContext, topLevelLinks ??= new TopLevelLinks()); } return(topLevelLinks); }
private string GetRelationshipId() { var resource = _currentRequest.GetRequestResource(); if (!_currentRequest.IsRelationshipPath) { return(null); } var components = SplitCurrentPath(); var toReturn = components.ElementAtOrDefault(4); if (toReturn == null) { return(null); } var relType = _currentRequest.RequestRelationship.RightType; var relResource = _resourceGraph.GetResourceContext(relType); var relIdentityType = relResource.IdentityType; return(toReturn); }