-
Notifications
You must be signed in to change notification settings - Fork 475
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Instance annotations to WebAPI (#2219)
* InstanceAnnotationChanges InstanceAnnotationChanges * Update ODataResourceDeserializerTests.cs * Add review comments * Review comment fix * Code review changes Code review changes * updates * Update ODataResourceSerializer.cs * changes after rebase * InstanceAnnotationChanges InstanceAnnotationChanges * Add review comments * Review comment fix * Code review changes Code review changes * Update Microsoft.AspNet.OData.PublicApi.bsl * public api * public api change * Address comments * Changes * Update ODataResourceSerializer.cs * changes * Comment changes * Update ODataResourceSerializer.cs * publi api * comment chantes * extra test * Update GlobalSuppressions.cs * name change * changes * changes and test * Update ODataResourceValueSerializer.cs * changes * Update ODataResourceValueSerializer.cs * changes * changes * updates * Update ODataInstanceAnnotationContainer.cs
- Loading branch information
1 parent
e812738
commit 1f48bed
Showing
43 changed files
with
3,482 additions
and
166 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
59 changes: 59 additions & 0 deletions
59
src/Microsoft.AspNet.OData.Shared/Builder/IODataInstanceAnnotationContainer.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,59 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace Microsoft.AspNet.OData.Builder | ||
{ | ||
/// <summary> | ||
/// Interface to used as a Container for holding Instance Annotations, An default implementation is provided | ||
/// Custoer can implement the interface and can have their own implementation. | ||
/// </summary> | ||
public interface IODataInstanceAnnotationContainer | ||
{ | ||
/// <summary> | ||
/// Method to Add an Instance Annotation to the CLR type | ||
/// </summary> | ||
/// <param name="annotationName">Name of Annotation</param> | ||
/// <param name="value">Value of Annotation</param> | ||
void AddResourceAnnotation(string annotationName, object value); | ||
|
||
/// <summary> | ||
/// Method to Add an Instance Annotation to a property | ||
/// </summary> | ||
/// <param name="propertyName">Name of the property</param> | ||
/// <param name="annotationName">Name of Annotation</param> | ||
/// <param name="value">Value of Annotation</param> | ||
void AddPropertyAnnotation(string propertyName, string annotationName, object value); | ||
|
||
/// <summary> | ||
/// Get an Instance Annotation from CLR Type | ||
/// </summary> | ||
/// <param name="annotationName">Name of Annotation</param> | ||
/// <returns>Get Annotation value for the given annotation</returns> | ||
object GetResourceAnnotation(string annotationName); | ||
|
||
/// <summary> | ||
/// Get an Instance Annotation from the Property | ||
/// </summary> | ||
/// <param name="propertyName">Name of the Property</param> | ||
/// <param name="annotationName">Name of the Annotation</param> | ||
/// <returns>Get Annotation value for the given annotation and property</returns> | ||
object GetPropertyAnnotation(string propertyName, string annotationName); | ||
|
||
/// <summary> | ||
/// Get All Annotations from CLR Type | ||
/// </summary> | ||
/// <returns>Dictionary of string(annotation name) and object value(annotation value)</returns> | ||
IDictionary<string,object> GetResourceAnnotations(); | ||
|
||
/// <summary> | ||
/// Get all Annotations for a Property | ||
/// </summary> | ||
/// <param name="propertyName">Name of Property</param> | ||
/// <returns>Dictionary of string(annotation name) and object value(annotation value)</returns> | ||
IDictionary<string, object> GetPropertyAnnotations(string propertyName); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/Microsoft.AspNet.OData.Shared/Builder/InstanceAnnotationContainerAnnotation.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,41 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
||
using System.Reflection; | ||
using Microsoft.AspNet.OData.Common; | ||
using Microsoft.OData.Edm; | ||
|
||
namespace Microsoft.AspNet.OData.Builder | ||
{ | ||
/// <summary> | ||
/// This annotation indicates the mapping from a <see cref="IEdmStructuredType"/> to a <see cref="PropertyInfo"/>. | ||
/// The <see cref="IEdmStructuredType"/> is a type of IODataInstanceAnnotationContainer and the <see cref="PropertyInfo"/> is the specific | ||
/// property which is used to save/retrieve the instance annotations. | ||
/// </summary> | ||
internal class ODataInstanceAnnotationContainerAnnotation | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of <see cref="ODataInstanceAnnotationContainerAnnotation"/> class. | ||
/// </summary> | ||
/// <param name="propertyInfo">The backing <see cref="PropertyInfo"/>.</param> | ||
public ODataInstanceAnnotationContainerAnnotation(PropertyInfo propertyInfo) | ||
{ | ||
if (propertyInfo == null) | ||
{ | ||
throw Error.ArgumentNull("propertyInfo"); | ||
} | ||
|
||
TypeHelper.ValidateAssignableFromForArgument(typeof(IODataInstanceAnnotationContainer), propertyInfo.PropertyType, "IODataInstanceAnnotationContainer"); | ||
|
||
PropertyInfo = propertyInfo; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the <see cref="PropertyInfo"/> which backs the instance annotations of the clr type/resource etc. | ||
/// </summary> | ||
public PropertyInfo PropertyInfo | ||
{ | ||
get; | ||
} | ||
} | ||
} |
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
Oops, something went wrong.