-
Notifications
You must be signed in to change notification settings - Fork 356
ODL9: Cherry-pick - Add ShouldReadPropertyAsStream API to allow access to property annotations #3488
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
WanjohiSammy
wants to merge
2
commits into
dev-9.x
Choose a base branch
from
cherrypick/2f80bcedc36e05b2d68f9dfa484643ec62a6d89b
base: dev-9.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
ODL9: Cherry-pick - Add ShouldReadPropertyAsStream API to allow access to property annotations #3488
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -197,8 +197,23 @@ public ODataMessageQuotas MessageQuotas | |
| /// Function returns: | ||
| /// * True, to have the value streamed, otherwise false | ||
| /// </Remarks> | ||
| [Obsolete("Use 'ShouldReadPropertyAsStream' instead, which provides access to property annotations. ReadAsStreamFunc will be removed in a future ODL 9 release.")] | ||
| public Func<IEdmPrimitiveType, bool, string, IEdmProperty, bool> ReadAsStreamFunc { get; set; } | ||
|
|
||
| /// <summary> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we consider to make it as a service into the DI? |
||
| /// Func to evaluate whether a property should be read as a stream. This function provides access to property annotations, enabling | ||
| /// scenarios where the decision to read as stream depends on annotations. Note that IEdmProperty may be null when reading within a collection. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// <see cref="ODataPropertyStreamingContext"/> provides: | ||
| /// * Primitive type of the value being read, or null if unknown | ||
| /// * Whether the value being read is a collection | ||
| /// * The name of the property being read (null for values within a collection) | ||
| /// * The property being read (null for dynamic property or value within a collection) | ||
| /// * Custom property annotations (non-OData annotations) that have been read so far. | ||
| /// </remarks> | ||
| public Func<ODataPropertyStreamingContext, bool> ShouldReadPropertyAsStream { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Func to evaluate whether an annotation should be read or skipped by the reader. The func should return true if the annotation should | ||
| /// be read and false if the annotation should be skipped. A null value indicates that all annotations should be skipped. | ||
|
|
@@ -309,6 +324,7 @@ private void CopyFrom(ODataMessageReaderSettings other) | |
| this.LibraryCompatibility = other.LibraryCompatibility; | ||
| this.Version = other.Version; | ||
| this.ReadAsStreamFunc = other.ReadAsStreamFunc; | ||
| this.ShouldReadPropertyAsStream = other.ShouldReadPropertyAsStream; | ||
| this.ArrayPool = other.ArrayPool; | ||
| this.EnablePropertyNameCaseInsensitive = other.EnablePropertyNameCaseInsensitive; | ||
| this.EnableReadingKeyAsSegment = other.EnableReadingKeyAsSegment; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| //--------------------------------------------------------------------- | ||
| // <copyright file="ODataPropertyStreamingContext.cs" company="Microsoft"> | ||
| // Copyright (C) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information. | ||
| // </copyright> | ||
| //--------------------------------------------------------------------- | ||
|
|
||
| using System.Collections.Generic; | ||
| using Microsoft.OData.Edm; | ||
|
|
||
| namespace Microsoft.OData | ||
| { | ||
| /// <summary> | ||
| /// Context information for reading an OData property | ||
| /// </summary> | ||
| public class ODataPropertyStreamingContext | ||
| { | ||
| /// <summary> | ||
| /// The primitive type of the property being read, or null if unknown. | ||
| /// </summary> | ||
| public IEdmPrimitiveType PrimitiveType { get; internal set; } | ||
|
|
||
| /// <summary> | ||
| /// Indicates whether the value being read is a collection. | ||
| /// </summary> | ||
| public bool IsCollection { get; internal set; } | ||
|
|
||
| /// <summary> | ||
| /// The name of the property being read (null for values within a collection) | ||
| /// </summary> | ||
| public string PropertyName { get; internal set; } | ||
|
|
||
| /// <summary> | ||
| /// The EDM property being read (null for dynamic property or value within a collection) | ||
| /// </summary> | ||
| public IEdmProperty Property { get; internal set; } | ||
|
|
||
| /// <summary> | ||
| /// The custom annotations associated with this property. | ||
| /// These are annotations that do not correspond to reserved OData annotations, | ||
| /// regardless of whether the optional "odata." prefix is present. | ||
| /// </summary> | ||
| public IEnumerable<KeyValuePair<string, object>> CustomPropertyAnnotations { get; internal set; } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| Microsoft.OData.ODataMessageReaderSettings.ShouldReadPropertyAsStream.get -> System.Func<Microsoft.OData.ODataPropertyStreamingContext, bool> | ||
| Microsoft.OData.ODataMessageReaderSettings.ShouldReadPropertyAsStream.set -> void | ||
| Microsoft.OData.ODataPropertyStreamingContext | ||
| Microsoft.OData.ODataPropertyStreamingContext.CustomPropertyAnnotations.get -> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, object>> | ||
| Microsoft.OData.ODataPropertyStreamingContext.IsCollection.get -> bool | ||
| Microsoft.OData.ODataPropertyStreamingContext.ODataPropertyStreamingContext() -> void | ||
| Microsoft.OData.ODataPropertyStreamingContext.PrimitiveType.get -> Microsoft.OData.Edm.IEdmPrimitiveType | ||
| Microsoft.OData.ODataPropertyStreamingContext.Property.get -> Microsoft.OData.Edm.IEdmProperty | ||
| Microsoft.OData.ODataPropertyStreamingContext.PropertyName.get -> string |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IsCollection, PropertyName ... are hardcoded, It seems no sense?
We don't have the IEdmProperty for the declared property reading?