-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLatitude.cs
More file actions
42 lines (35 loc) · 1 KB
/
Latitude.cs
File metadata and controls
42 lines (35 loc) · 1 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
namespace ValueObjects.Location
{
public class Latitude : ValueObject
{
private readonly float value;
private Latitude(float value)
{
if (value < -90 || value > 90)
{
throw new ArgumentOutOfRangeException(nameof(value), value, "Latitude must be in range [-90; 90]");
}
this.value = value;
}
public static Latitude FromScalar(float value)
{
return new Latitude(value);
}
public static implicit operator float(Latitude latitude)
{
return latitude.value;
}
public static explicit operator Latitude(float value)
{
return new Latitude(value);
}
protected override IEnumerable<object> GetAtomicValues()
{
yield return value;
}
public override string ToString()
{
return value.ToString();
}
}
}