Skip to content

Commit eff9c81

Browse files
Use Math.Clamp
1 parent c870521 commit eff9c81

File tree

2 files changed

+10
-174
lines changed

2 files changed

+10
-174
lines changed

src/ImageSharp.Web/Commands/ComparableExtensions.cs

Lines changed: 0 additions & 164 deletions
This file was deleted.

src/ImageSharp.Web/Commands/Converters/IntegralNumberConverter.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Six Labors.
1+
// Copyright (c) Six Labors.
22
// Licensed under the Apache License, Version 2.0.
33

44
using System;
@@ -27,39 +27,39 @@ public override object ConvertFrom(CultureInfo culture, string value, Type prope
2727
// Now clamp it to the type ranges
2828
if (propertyType == TypeConstants.Sbyte)
2929
{
30-
rounded = rounded.Clamp(sbyte.MinValue, sbyte.MaxValue);
30+
rounded = Math.Clamp(rounded, sbyte.MinValue, sbyte.MaxValue);
3131
}
3232
else if (propertyType == TypeConstants.Byte)
3333
{
34-
rounded = rounded.Clamp(byte.MinValue, byte.MaxValue);
34+
rounded = Math.Clamp(rounded, byte.MinValue, byte.MaxValue);
3535
}
3636
else if (propertyType == TypeConstants.Short)
3737
{
38-
rounded = rounded.Clamp(short.MinValue, short.MaxValue);
38+
rounded = Math.Clamp(rounded, short.MinValue, short.MaxValue);
3939
}
4040
else if (propertyType == TypeConstants.UShort)
4141
{
42-
rounded = rounded.Clamp(ushort.MinValue, ushort.MaxValue);
42+
rounded = Math.Clamp(rounded, ushort.MinValue, ushort.MaxValue);
4343
}
4444
else if (propertyType == TypeConstants.Int)
4545
{
46-
rounded = rounded.Clamp(int.MinValue, int.MaxValue);
46+
rounded = Math.Clamp(rounded, int.MinValue, int.MaxValue);
4747
}
4848
else if (propertyType == TypeConstants.UInt)
4949
{
50-
rounded = rounded.Clamp(uint.MinValue, uint.MaxValue);
50+
rounded = Math.Clamp(rounded, uint.MinValue, uint.MaxValue);
5151
}
5252
else if (propertyType == TypeConstants.Long)
5353
{
54-
rounded = rounded.Clamp(long.MinValue, long.MaxValue);
54+
rounded = Math.Clamp(rounded, long.MinValue, long.MaxValue);
5555
}
5656
else if (propertyType == TypeConstants.ULong)
5757
{
58-
rounded = rounded.Clamp(ulong.MinValue, ulong.MaxValue);
58+
rounded = Math.Clamp(rounded, ulong.MinValue, ulong.MaxValue);
5959
}
6060

6161
// Now it's rounded an clamped we should be able to correctly parse the string.
6262
return (T)Convert.ChangeType(rounded.ToString(CultureInfo.InvariantCulture), typeof(T), culture);
6363
}
6464
}
65-
}
65+
}

0 commit comments

Comments
 (0)