-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDimensions.cs
More file actions
56 lines (45 loc) · 1.71 KB
/
Copy pathDimensions.cs
File metadata and controls
56 lines (45 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
namespace EasyKeys.Shipping.Abstractions.Models;
#pragma warning disable CS0660 // Type defines operator == or operator != but does not override Object.Equals(object o)
#pragma warning disable CS0661 // Type defines operator == or operator != but does not override Object.GetHashCode()
public struct Dimensions
#pragma warning restore CS0661 // Type defines operator == or operator != but does not override Object.GetHashCode()
#pragma warning restore CS0660 // Type defines operator == or operator != but does not override Object.Equals(object o)
{
public Dimensions(
decimal length,
decimal width,
decimal height)
{
Length = length;
Width = width;
Height = height;
}
public decimal Length { get; set; }
public decimal RoundedLength => Math.Max(1, Math.Ceiling(Length));
public decimal Width { get; set; }
public decimal RoundedWidth => Math.Max(1, Math.Ceiling(Width));
public decimal Height { get; set; }
public decimal RoundedHeight => Math.Max(1, Math.Ceiling(Height));
/// <summary>
/// Package measurement is (w*2) + (h*2) + l.
/// This is used to determine if the package is oversize or not.
/// </summary>
public decimal Measurement
{
get
{
var result = (Width * 2) + (Height * 2) + Length;
return Math.Ceiling(result);
}
}
public decimal Girth
{
get
{
var result = (Width * 2) + (Height * 2);
return Math.Ceiling(result);
}
}
public static bool operator ==(Dimensions dim1, Dimensions dim2) => dim1.Equals(dim2);
public static bool operator !=(Dimensions dim1, Dimensions dim2) => !dim1.Equals(dim2);
}