mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-06-21 21:46:27 +02:00
Version 3.0.381
This commit is contained in:
parent
f963c0a219
commit
3a363acf3a
1525 changed files with 60589 additions and 125098 deletions
14
SharedBusinessLogic/Model/Map/IMapSpan.cs
Normal file
14
SharedBusinessLogic/Model/Map/IMapSpan.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
namespace ShareeBike.Model.Map
|
||||
{
|
||||
public interface IMapSpan
|
||||
{
|
||||
/// <summary> Center of map displayed area.</summary>
|
||||
IPosition Center { get; }
|
||||
|
||||
/// <summary> Radius of displayed map area. </summary>
|
||||
double Radius { get; }
|
||||
|
||||
/// <summary> Gets if map span is valid or not. </summary>
|
||||
bool IsValid { get; }
|
||||
}
|
||||
}
|
30
SharedBusinessLogic/Model/Map/MapSpan.cs
Normal file
30
SharedBusinessLogic/Model/Map/MapSpan.cs
Normal file
|
@ -0,0 +1,30 @@
|
|||
using System;
|
||||
|
||||
namespace ShareeBike.Model.Map
|
||||
{
|
||||
/// <summary> Holds the displayed map area. </summary>
|
||||
public class MapSpan : IMapSpan
|
||||
{
|
||||
internal MapSpan(IPosition center, double radius)
|
||||
{
|
||||
if (!GetIsValid(center, radius))
|
||||
throw new ArgumentNullException();
|
||||
|
||||
Center = center;
|
||||
Radius = radius;
|
||||
}
|
||||
|
||||
/// <summary> Center of map displayed area.</summary>
|
||||
public IPosition Center { get; }
|
||||
|
||||
/// <summary> Radius of displayed map area. </summary>
|
||||
public double Radius { get; }
|
||||
|
||||
public bool IsValid => GetIsValid(Center, Radius);
|
||||
|
||||
public static bool GetIsValid(IPosition center, double radius)
|
||||
=> center != null
|
||||
&& center.IsValid
|
||||
&& !double.IsNaN(radius);
|
||||
}
|
||||
}
|
11
SharedBusinessLogic/Model/Map/MapSpanFactory.cs
Normal file
11
SharedBusinessLogic/Model/Map/MapSpanFactory.cs
Normal file
|
@ -0,0 +1,11 @@
|
|||
|
||||
namespace ShareeBike.Model.Map
|
||||
{
|
||||
public static class MapSpanFactory
|
||||
{
|
||||
public static IMapSpan Create(IPosition position = null, double radius = double.NaN)
|
||||
=> MapSpan.GetIsValid(position, radius)
|
||||
? new MapSpan(position, radius) as IMapSpan
|
||||
: new NullMapSpan();
|
||||
}
|
||||
}
|
16
SharedBusinessLogic/Model/Map/NullMapSpan.cs
Normal file
16
SharedBusinessLogic/Model/Map/NullMapSpan.cs
Normal file
|
@ -0,0 +1,16 @@
|
|||
|
||||
namespace ShareeBike.Model.Map
|
||||
{
|
||||
public class NullMapSpan : IMapSpan
|
||||
{
|
||||
internal NullMapSpan() { }
|
||||
|
||||
/// <summary> Center of map displayed area.</summary>
|
||||
public IPosition Center { get; } = PositionFactory.Create();
|
||||
|
||||
/// <summary> Radius of displayed map area. </summary>
|
||||
public double Radius => double.NaN;
|
||||
|
||||
public bool IsValid => MapSpan.GetIsValid(Center, Radius);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue