示例#1
0
    private IDictionary <string, object>?ExtractData(AnnotatedEntry entry, bool includeAnnotations)
    {
        if (entry == null || entry.Data == null)
        {
            return(null);
        }

        return(includeAnnotations ? DataWithAnnotations(entry.Data, entry.Annotations) : entry.Data);
    }
    private async Task EnrichWithMediaPropertiesAsync(AnnotatedEntry entry, IEnumerable <string> mediaProperties, CancellationToken cancellationToken)
    {
        if (entry != null && mediaProperties != null)
        {
            var entityMediaPropertyName = mediaProperties.FirstOrDefault(x => !entry.Data.ContainsKey(x));
            entityMediaPropertyName ??= FluentCommand.AnnotationsLiteral;
            if (entry.Annotations != null)
            {
                await GetMediaStreamValueAsync(entry.Data, entityMediaPropertyName, entry.Annotations.MediaResource, cancellationToken).ConfigureAwait(false);
            }

            foreach (var propertyName in mediaProperties)
            {
                if (entry.Data.TryGetValue(propertyName, out var value))
                {
                    await GetMediaStreamValueAsync(entry.Data, propertyName, value as ODataMediaAnnotations, cancellationToken).ConfigureAwait(false);
                }
            }
        }
    }
示例#3
0
    private IDictionary <string, object>?ExtractDictionary(AnnotatedEntry entry, bool includeAnnotations)
    {
        if (entry == null || entry.Data == null)
        {
            return(null);
        }

        var data = entry.Data;

        if (data.Keys.Count == 1 && data.ContainsKey(FluentCommand.ResultLiteral) &&
            data.Values.First() is IDictionary <string, object> )
        {
            return(data.Values.First() as IDictionary <string, object>);
        }
        else if (includeAnnotations)
        {
            return(DataWithAnnotations(data, entry.Annotations));
        }
        else
        {
            return(data);
        }
    }