roadie/Roadie.Api.Library/Extensions/ShortExt.cs

18 lines
646 B
C#
Raw Normal View History

2018-11-04 20:33:37 +00:00
namespace Roadie.Library.Extensions
2018-11-03 21:21:36 +00:00
{
public static class ShortExt
{
public static short? Or(this short? value, short? alternative)
{
2019-07-03 16:21:29 +00:00
if (!value.HasValue && !alternative.HasValue) return null;
2018-11-03 21:21:36 +00:00
return value.HasValue ? value : alternative;
}
public static short? TakeLarger(this short? value, short? alternative)
{
2019-07-03 16:21:29 +00:00
if (!value.HasValue && !alternative.HasValue) return null;
if (!value.HasValue && alternative.HasValue) return alternative.Value;
2018-11-03 21:21:36 +00:00
return value.Value > alternative.Value ? value.Value : alternative.Value;
}
}
2018-11-04 20:33:37 +00:00
}