-
Notifications
You must be signed in to change notification settings - Fork 352
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement type facets promotion in URI parsing #654
- Loading branch information
Showing
14 changed files
with
836 additions
and
143 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
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
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
50 changes: 50 additions & 0 deletions
50
src/Microsoft.OData.Core/UriParser/TypeFacetsPromotionRules.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,50 @@ | ||
//--------------------------------------------------------------------- | ||
// <copyright file="TypeFacetsPromotionRules.cs" company="Microsoft"> | ||
// Copyright (C) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information. | ||
// </copyright> | ||
//--------------------------------------------------------------------- | ||
|
||
namespace Microsoft.OData.Core.UriParser | ||
{ | ||
using System; | ||
|
||
/// <summary> | ||
/// Defines the promotion rules for type facets. | ||
/// </summary> | ||
public class TypeFacetsPromotionRules | ||
{ | ||
/// <summary> | ||
/// Computes the promoted precision value for left and right. | ||
/// The default implementation works as follows: | ||
/// 1) if both left and right are null, return null; | ||
/// 2) if only one is null, return the other; | ||
/// 3) otherwise, return the larger. | ||
/// </summary> | ||
/// <param name="left">Left-hand-side precision value.</param> | ||
/// <param name="right">Right-hand-side precision value.</param> | ||
/// <returns>The promoted precision value.</returns> | ||
public virtual int? GetPromotedPrecision(int? left, int? right) | ||
{ | ||
return left == null ? right : | ||
right == null ? left : | ||
Math.Max((int)left, (int)right); | ||
} | ||
|
||
/// <summary> | ||
/// Computes the promoted scale value for left and right. | ||
/// The default implementation works as follows: | ||
/// 1) if both left and right are null, return null; | ||
/// 2) if only one is null, return the other; | ||
/// 3) otherwise, return the larger. | ||
/// </summary> | ||
/// <param name="left">Left-hand-side scale value.</param> | ||
/// <param name="right">Right-hand-side scale value.</param> | ||
/// <returns>The promoted scale value.</returns> | ||
public virtual int? GetPromotedScale(int? left, int? right) | ||
{ | ||
return left == null ? right : | ||
right == null ? left : | ||
Math.Max((int)left, (int)right); | ||
} | ||
} | ||
} |
Oops, something went wrong.