Skip to content

Commit

Permalink
Clean up GenerateRelationalOperators a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
Muximize committed Jan 9, 2024
1 parent d6cb7d1 commit 443d8c5
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -761,12 +761,12 @@ private void GenerateRelationalOperators()
var rightParameter = relation.RightQuantity.Name.ToCamelCase();
var rightConversionProperty = relation.RightUnit.PluralName;

if (relation.LeftQuantity.Name == "TimeSpan")
if (relation.LeftQuantity.Name is nameof(TimeSpan))
{
leftConversionProperty = "Total" + leftConversionProperty;
}

if (relation.RightQuantity.Name == "TimeSpan")
if (relation.RightQuantity.Name is nameof(TimeSpan))
{
rightConversionProperty = "Total" + rightConversionProperty;
}
Expand All @@ -780,16 +780,14 @@ private void GenerateRelationalOperators()
var leftPart = $"{leftParameter}.{leftConversionProperty}";
var rightPart = $"{rightParameter}.{rightConversionProperty}";

if (leftParameter == "double")
if (leftParameter is "double")
{
leftParameter = "value";
leftPart = "value";
leftParameter = leftPart = "value";
}

if (rightParameter == "double")
if (rightParameter is "double")
{
rightParameter = "value";
rightPart = "value";
rightParameter = rightPart = "value";
}

var leftCast = relation.LeftQuantity.ValueType is "decimal" ? "(double)" : string.Empty;
Expand Down

0 comments on commit 443d8c5

Please sign in to comment.