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