-
Notifications
You must be signed in to change notification settings - Fork 351
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Retrieve the content type for stream property from vocabulary annotat…
…ion by convention (#1995) * Retrieve the content type for stream property form vocabulary annotation by default * Address the comments * Fix failing test cases
- Loading branch information
Showing
6 changed files
with
102 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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 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 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 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
43 changes: 43 additions & 0 deletions
43
src/Microsoft.OData.Edm/Vocabularies/VocabularyAnnotationExtensions.cs
This file contains 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,43 @@ | ||
//--------------------------------------------------------------------- | ||
// <copyright file="VocabularyAnnotationExtensions.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 System.Linq; | ||
|
||
namespace Microsoft.OData.Edm.Vocabularies.V1 | ||
{ | ||
/// <summary> | ||
/// Extension methods for the vocabulary annotations. | ||
/// </summary> | ||
public static class VocabularyAnnotationExtensions | ||
{ | ||
/// <summary> | ||
/// Gets the collection of string for a target annotatable. | ||
/// </summary> | ||
/// <param name="model">The model referenced to.</param> | ||
/// <param name="target">The target annotatable to find annotation.</param> | ||
/// <param name="term">The target annotatable to find annotation.</param> | ||
/// <returns>Null or a collection string of qualified type name.</returns> | ||
public static IEnumerable<string> GetVocabularyStringCollection(this IEdmModel model, IEdmVocabularyAnnotatable target, IEdmTerm term) | ||
{ | ||
EdmUtil.CheckArgumentNull(model, "model"); | ||
EdmUtil.CheckArgumentNull(target, "target"); | ||
EdmUtil.CheckArgumentNull(target, "term"); | ||
|
||
IEdmVocabularyAnnotation annotation = model.FindVocabularyAnnotations<IEdmVocabularyAnnotation>(target, term).FirstOrDefault(); | ||
if (annotation != null) | ||
{ | ||
IEdmCollectionExpression collectionExpression = annotation.Value as IEdmCollectionExpression; | ||
if (collectionExpression != null && collectionExpression.Elements != null) | ||
{ | ||
return collectionExpression.Elements.OfType<IEdmStringConstantExpression>().Select(e => e.Value); | ||
} | ||
} | ||
|
||
return Enumerable.Empty<string>(); | ||
} | ||
} | ||
} |
This file contains 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