protected void StartFeed(Stack <ResponseNode> nodeStack, ODataFeedAnnotations feedAnnotations) { nodeStack.Push(new ResponseNode { Feed = new AnnotatedFeed(new List <AnnotatedEntry>()), }); }
public async Task <IEnumerable <T> > ReadAsCollectionAsync(ODataFeedAnnotations annotations, CancellationToken cancellationToken) { if (_responseMessage.IsSuccessStatusCode && _responseMessage.StatusCode != HttpStatusCode.NoContent && (_request.Method == RestVerbs.Get || _request.ResultRequired)) { var responseReader = _session.Adapter.GetResponseReader(); var response = await responseReader.GetResponseAsync(_responseMessage).ConfigureAwait(false); if (cancellationToken.IsCancellationRequested) { cancellationToken.ThrowIfCancellationRequested(); } if (annotations != null && response.Feed != null) { annotations.CopyFrom(response.Feed.Annotations); } var result = response.AsEntries(_session.Settings.IncludeAnnotationsInResults); return(result.Select(x => x.ToObject <T>(TypeCache))); } else { return(Array.Empty <T>()); } }
internal void Merge(ODataFeedAnnotations src) { this.Id = this.Id ?? src.Id; this.Count = this.Count ?? src.Count; this.DeltaLink = this.DeltaLink ?? src.DeltaLink; this.NextPageLink = this.NextPageLink ?? src.NextPageLink; this.InstanceAnnotations = this.InstanceAnnotations ?? src.InstanceAnnotations; }
internal void CopyFrom(ODataFeedAnnotations src) { this.Id = src.Id; this.Count = src.Count; this.DeltaLink = src.DeltaLink; this.NextPageLink = src.NextPageLink; this.InstanceAnnotations = src.InstanceAnnotations; }
protected void StartFeed(Stack <ResponseNode> nodeStack, ODataFeedAnnotations feedAnnotations) { nodeStack.Push(new ResponseNode { Feed = new List <IDictionary <string, object> >(), FeedAnnotations = feedAnnotations, }); }
public void SetLinkAnnotations(ODataFeedAnnotations annotations) { if (this.LinkAnnotations == null) { this.LinkAnnotations = annotations; } else { this.LinkAnnotations.Merge(annotations); } }
public async Task <IEnumerable <T> > FindEntriesAsync(Uri annotatedUri, ODataFeedAnnotations annotations, CancellationToken cancellationToken) { var commandText = annotatedUri.AbsoluteUri; if (cancellationToken.IsCancellationRequested) { cancellationToken.ThrowIfCancellationRequested(); } var result = _client.FindEntriesAsync(commandText, annotations, cancellationToken); return(await RectifyColumnSelectionAsync(result, _command.SelectedColumns)); }
public async Task <IEnumerable <T> > FindEntriesAsync(ODataFeedAnnotations annotations, CancellationToken cancellationToken) { var commandText = await _command.WithCount().GetCommandTextAsync(cancellationToken); if (cancellationToken.IsCancellationRequested) { cancellationToken.ThrowIfCancellationRequested(); } var result = _client.FindEntriesAsync(commandText, annotations, cancellationToken); return(await RectifyColumnSelectionAsync( result, _command.SelectedColumns, _command.DynamicPropertiesContainerName)); }
public async Task <IEnumerable <T> > FindEntriesAsync(Uri annotatedUri, ODataFeedAnnotations annotations, CancellationToken cancellationToken) { var commandText = annotatedUri.AbsoluteUri; if (cancellationToken.IsCancellationRequested) { cancellationToken.ThrowIfCancellationRequested(); } var result = _client.FindEntriesAsync(commandText, annotations, cancellationToken); return(await FilterAndTypeColumnsAsync( result, _command.SelectedColumns, _command.DynamicPropertiesContainerName).ConfigureAwait(false)); }
protected void EndFeed(Stack <ResponseNode> nodeStack, ODataFeedAnnotations feedAnnotations, ref ResponseNode rootNode) { var feedNode = nodeStack.Pop(); if (nodeStack.Any()) { nodeStack.Peek().Feed = feedNode.Feed; } else { rootNode = feedNode; } feedNode.Feed.SetAnnotations(feedAnnotations); }
public async Task <IEnumerable <T> > FindEntriesAsync(ODataFeedAnnotations annotations, CancellationToken cancellationToken) { await _session.ResolveAdapterAsync(cancellationToken); var command = _command.WithCount().Resolve(_session); if (cancellationToken.IsCancellationRequested) { cancellationToken.ThrowIfCancellationRequested(); } var result = _client.FindEntriesAsync(command.Format(), annotations, cancellationToken); return(await FilterAndTypeColumnsAsync( result, _command.SelectedColumns, _command.DynamicPropertiesContainerName).ConfigureAwait(false)); }
internal void CopyFrom(ODataFeedAnnotations src) { if (src != null) { this.Id = src.Id; this.Count = src.Count; this.DeltaLink = src.DeltaLink; this.NextPageLink = src.NextPageLink; this.InstanceAnnotations = src.InstanceAnnotations; } else { this.Id = null; this.Count = null; this.DeltaLink = null; this.NextPageLink = null; this.InstanceAnnotations = null; } }
protected void EndFeed(Stack <ResponseNode> nodeStack, ODataFeedAnnotations feedAnnotations, ref ResponseNode rootNode) { var feedNode = nodeStack.Pop(); var entries = feedNode.Feed; if (nodeStack.Any()) { nodeStack.Peek().Feed = entries; } else { rootNode = feedNode; } if (feedNode.FeedAnnotations == null) { feedNode.FeedAnnotations = feedAnnotations; } else { feedNode.FeedAnnotations.Merge(feedAnnotations); } }
public AnnotatedFeed(IEnumerable <AnnotatedEntry> entries, ODataFeedAnnotations annotations = null) { this.Entries = entries.ToList(); this.Annotations = annotations; }
public Task <IEnumerable <T> > FindEntriesAsync(Uri annotatedUri, ODataFeedAnnotations annotations) { return(FindEntriesAsync(annotatedUri, annotations, CancellationToken.None)); }
/// <summary> /// Executes the OData function and returns an array. /// </summary> /// <param name="cancellationToken">The cancellation token.</param> /// <param name="annotations">The OData feed annotations.</param> /// <returns>Execution result.</returns> public Task <T[]> ExecuteAsArrayAsync(ODataFeedAnnotations annotations, CancellationToken cancellationToken) { return(ExecuteAsArrayAsync <T>(annotations, cancellationToken)); }
internal async Task <IEnumerable <IDictionary <string, object> > > FindEntriesAsync(FluentCommand command, ODataFeedAnnotations annotations, CancellationToken cancellationToken) { if (IsBatchResponse) { annotations.CopyFrom(_batchResponse.Annotations); return(_batchResponse.AsEntries()); } await _session.ResolveAdapterAsync(cancellationToken); if (cancellationToken.IsCancellationRequested) { cancellationToken.ThrowIfCancellationRequested(); } var commandText = await command.GetCommandTextAsync(cancellationToken); if (cancellationToken.IsCancellationRequested) { cancellationToken.ThrowIfCancellationRequested(); } return(await FindEntriesAsync(commandText, annotations, cancellationToken)); }
public async Task <IEnumerable <IDictionary <string, object> > > FindEntriesAsync(string commandText, ODataFeedAnnotations annotations, CancellationToken cancellationToken) { if (IsBatchResponse) { annotations.CopyFrom(_batchResponse.Annotations); return(_batchResponse.AsEntries()); } await _session.ResolveAdapterAsync(cancellationToken); if (cancellationToken.IsCancellationRequested) { cancellationToken.ThrowIfCancellationRequested(); } var request = await _session.Adapter.GetRequestWriter(_lazyBatchWriter) .CreateGetRequestAsync(commandText, false); return(await ExecuteRequestWithResultAsync(request, cancellationToken, x => { annotations.CopyFrom(x.Annotations); return x.Entries; }, () => new[] { (IDictionary <string, object>)null })); }
public Task <IEnumerable <T> > ReadAsCollectionAsync(ODataFeedAnnotations annotations) { return(ReadAsCollectionAsync(annotations, CancellationToken.None)); }
public static ODataResponse FromFeed(IEnumerable <IDictionary <string, object> > entries, ODataFeedAnnotations annotations = null) { return(new ODataResponse { Entries = entries, Annotations = annotations, }); }
private async Task <IEnumerable <IDictionary <string, object> > > ExecuteActionAsync(ResolvedCommand command, ODataFeedAnnotations annotations, CancellationToken cancellationToken) { var entityTypeName = command.EntityCollection != null ? _session.Metadata.GetQualifiedTypeName(command.EntityCollection.Name) : null; var request = await _session.Adapter.GetRequestWriter(_lazyBatchWriter) .CreateActionRequestAsync(command.Format(), command.Details.ActionName, entityTypeName, command.CommandData, true, command.Details.Headers).ConfigureAwait(false); return(await ExecuteRequestWithResultAsync(request, cancellationToken, x => { var result = x.AsEntries(_session.Settings.IncludeAnnotationsInResults); if (annotations != null && x.Feed != null) { annotations.CopyFrom(x.Feed.Annotations); } return result; }, () => Array.Empty <IDictionary <string, object> >()).ConfigureAwait(false)); }
private static ODataResponse FromFeed(ITypeCache typeCache, IEnumerable <IDictionary <string, object> > entries, ODataFeedAnnotations feedAnnotations = null) { return(new ODataResponse(typeCache) { Feed = new AnnotatedFeed(entries.Select(x => new AnnotatedEntry(x)), feedAnnotations) }); }
public Task <IEnumerable <IDictionary <string, object> > > FindEntriesAsync(string commandText, ODataFeedAnnotations annotations) { return(FindEntriesAsync(commandText, annotations, CancellationToken.None)); }
/// <summary> /// Executes the OData function and returns an array. /// </summary> /// <param name="cancellationToken">The cancellation token.</param> /// <param name="annotations">The OData feed annotations.</param> /// <returns>Execution result.</returns> public Task <U[]> ExecuteAsArrayAsync <U>(ODataFeedAnnotations annotations, CancellationToken cancellationToken) { return(_client.ExecuteAsArrayAsync <U>(_command, annotations, cancellationToken)); }