roadie/Roadie.Api.Library/Extensions/ShortExt.cs
2020-06-21 15:39:14 -05:00

30 lines
No EOL
781 B
C#

namespace Roadie.Library.Extensions
{
public static class ShortExt
{
public static short? Or(this short? value, short? alternative)
{
if (!value.HasValue && !alternative.HasValue)
{
return null;
}
return value.HasValue ? value : alternative;
}
public static short? TakeLarger(this short? value, short? alternative)
{
if (!value.HasValue && !alternative.HasValue)
{
return null;
}
if (!value.HasValue && alternative.HasValue)
{
return alternative.Value;
}
return value.Value > alternative.Value ? value.Value : alternative.Value;
}
}
}