-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
task: added support for Minimum and Maximum constraints on Single sou…
…rce-gen types
- Loading branch information
Showing
16 changed files
with
184 additions
and
146 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
namespace Primitively; | ||
|
||
/// <summary> | ||
/// This class represents metadata properties common to all source generated Primitively numeric types. | ||
/// </summary> | ||
/// <param name="DataType">The <see cref="DataType"/> enum representation of the Primitively type.</param> | ||
/// <param name="Type">The .NET type of the Primitively type.</param> | ||
/// <param name="ValueType">The .NET type of the encapsulated value.</param> | ||
/// <param name="Example">An optional example of the integer.</param> | ||
/// <param name="CreateFrom">A function that creates an instance of the Primitively type from a string.</param> | ||
/// <param name="Minimum">The minimum value that can be set on the source generated Primitively type.</param> | ||
/// <param name="Maximum">The maximum value that can be set on the source generated Primitively type.</param> | ||
/// <param name="Digits">The number of fractional digits in the value on the source generated Primitively type</param> | ||
/// <param name="Mode">The rounding specification for how to round value of the source generated Primitively type | ||
/// if it is midway between two other numbers.</param> | ||
public record SingleInfo( | ||
DataType DataType, | ||
Type Type, | ||
Type ValueType, | ||
string? Example, | ||
Func<string?, IPrimitive> CreateFrom, | ||
float Minimum, | ||
float Maximum, | ||
int Digits, | ||
MidpointRounding Mode) | ||
: NumericInfo<float>(DataType, Type, ValueType, Example, CreateFrom, Minimum, Maximum); |
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 was deleted.
Oops, something went wrong.
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
8 changes: 8 additions & 0 deletions
8
src/Primitively/EmbeddedResources/Numeric/FloatingPoint/DoublePreMatchCheckMethod.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,8 @@ | ||
| ||
private static void PreMatchCheck(ref global::PRIMITIVE_VALUE_TYPE value) | ||
{ | ||
if (Digits >= 0) | ||
{ | ||
value = global::System.Math.Round(value, Digits, Mode); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/Primitively/EmbeddedResources/Numeric/FloatingPoint/SinglePreMatchCheckMethod.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,12 @@ | ||
| ||
private static void PreMatchCheck(ref global::PRIMITIVE_VALUE_TYPE value) | ||
{ | ||
if (Digits >= 0) | ||
{ | ||
#if NETCOREAPP2_0_OR_GREATER | ||
value = global::System.MathF.Round(value, Digits, Mode); | ||
#else | ||
value = (float)global::System.Math.Round(value, Digits, Mode); | ||
#endif | ||
} | ||
} |
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.