-
Notifications
You must be signed in to change notification settings - Fork 385
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sort inferred relations to keep generated operators in a consistent o…
…rder
- Loading branch information
Showing
2 changed files
with
19 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
// Licensed under MIT No Attribution, see LICENSE file at the root. | ||
// Copyright 2013 Andreas Gullberg Larsen ([email protected]). Maintained at https://github.com/angularsen/UnitsNet. | ||
|
||
using System; | ||
|
||
namespace CodeGen.JsonTypes | ||
{ | ||
internal record QuantityRelation | ||
internal record QuantityRelation : IComparable<QuantityRelation> | ||
{ | ||
public string Operator = null!; | ||
|
||
|
@@ -15,5 +17,18 @@ internal record QuantityRelation | |
|
||
public Quantity ResultQuantity = null!; | ||
public Unit ResultUnit = null!; | ||
|
||
private string SortString => ResultQuantity.Name | ||
+ ResultUnit.SingularName | ||
+ LeftQuantity.Name | ||
+ LeftUnit.SingularName | ||
+ Operator | ||
+ RightQuantity.Name | ||
+ RightUnit.SingularName; | ||
|
||
public int CompareTo(QuantityRelation? other) | ||
{ | ||
return string.Compare(SortString, other?.SortString, StringComparison.Ordinal); | ||
} | ||
} | ||
} |