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
106
SharedBusinessLogic/Model/Stations/StationCollection.cs
Normal file
106
SharedBusinessLogic/Model/Stations/StationCollection.cs
Normal file
|
@ -0,0 +1,106 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using ShareeBike.Model.Stations.StationNS;
|
||||
|
||||
namespace ShareeBike.Model.Stations
|
||||
{
|
||||
public class StationDictionary : IEnumerable<IStation>
|
||||
{
|
||||
/// <summary> Holds the list of stations. </summary>
|
||||
private readonly IDictionary<string, IStation> m_oStationDictionary;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a station by key.
|
||||
/// </summary>
|
||||
/// <param name="key">Key to get station.</param>
|
||||
/// <returns>Station for given key.</returns>
|
||||
public IStation this[string key] =>
|
||||
ContainsKey(key) ? m_oStationDictionary[key] : new NullStation();
|
||||
|
||||
/// <summary> Count of stations. </summary>
|
||||
public int Count { get { return m_oStationDictionary.Count; } }
|
||||
|
||||
public Version CopriVersion { get; }
|
||||
|
||||
/// <summary> Constructs a station dictionary object. </summary>
|
||||
/// <param name="version">Version of copri- service.</param>
|
||||
public StationDictionary(Version version = null, IDictionary<string, IStation> stations = null)
|
||||
{
|
||||
m_oStationDictionary = stations ?? new Dictionary<string, IStation>();
|
||||
|
||||
CopriVersion = version != null
|
||||
? new Version(version.Major, version.Minor, version.Revision, version.Build)
|
||||
: new Version(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
public IEnumerator<IStation> GetEnumerator()
|
||||
{
|
||||
return m_oStationDictionary.Values.GetEnumerator();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether a station by given key exists.
|
||||
/// </summary>
|
||||
/// <param name="key">Key to check.</param>
|
||||
/// <returns>True if station exists.</returns>
|
||||
public bool ContainsKey(string key)
|
||||
{
|
||||
return m_oStationDictionary.ContainsKey(key);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove a station by station id.
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
public void RemoveById(string id)
|
||||
{
|
||||
if (!m_oStationDictionary.ContainsKey(id))
|
||||
{
|
||||
// Nothing to do if there is no station with given name.
|
||||
return;
|
||||
}
|
||||
|
||||
m_oStationDictionary.Remove(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove a station by station name.
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
public IStation GetById(string id)
|
||||
{
|
||||
if (!m_oStationDictionary.ContainsKey(id))
|
||||
{
|
||||
// Nothing to do if there is no station with given name.
|
||||
return null;
|
||||
}
|
||||
|
||||
return m_oStationDictionary[id];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a station to dictionary of stations.
|
||||
/// </summary>
|
||||
/// <param name="p_oStation"></param>
|
||||
public void Add(Station p_oStation)
|
||||
{
|
||||
if (p_oStation == null)
|
||||
{
|
||||
throw new ArgumentException("Can not add empty station to collection of stations.");
|
||||
}
|
||||
|
||||
if (m_oStationDictionary.ContainsKey(p_oStation.Id))
|
||||
{
|
||||
throw new ArgumentException(string.Format("Can not add station {0} to collection of stations. A station with given name already exists.", p_oStation.Id));
|
||||
}
|
||||
|
||||
m_oStationDictionary.Add(p_oStation.Id, p_oStation);
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return m_oStationDictionary.Values.GetEnumerator();
|
||||
}
|
||||
}
|
||||
}
|
38
SharedBusinessLogic/Model/Stations/StationNS/IStation.cs
Normal file
38
SharedBusinessLogic/Model/Stations/StationNS/IStation.cs
Normal file
|
@ -0,0 +1,38 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ShareeBike.Model.Stations.StationNS.Operator;
|
||||
|
||||
namespace ShareeBike.Model.Stations.StationNS
|
||||
{
|
||||
/// <summary>
|
||||
/// Holds station information, i.e. static information like station name, station position and dynamic information like bikes available.
|
||||
/// </summary>
|
||||
public interface IStation
|
||||
{
|
||||
/// <summary> Holds the unique id of the station.c</summary>
|
||||
string Id { get; }
|
||||
|
||||
/// <summary> Holds the group to which the station belongs.</summary>
|
||||
IEnumerable<string> Group { get; }
|
||||
|
||||
/// <summary> Gets the name of the station.</summary>
|
||||
string StationName { get; }
|
||||
|
||||
/// <summary> Uri of the operator or null. </summary>
|
||||
Uri OperatorUri { get; }
|
||||
|
||||
/// <summary> Holds the gps- position of the station.</summary>
|
||||
IPosition Position { get; }
|
||||
|
||||
/// <summary> Holds operator related data.</summary>
|
||||
IData OperatorData { get; }
|
||||
|
||||
/// <summary> Gets the count of bikes available at station. </summary>
|
||||
int? AvailableBikesCount { get; }
|
||||
|
||||
/// <summary> Gets bike <see cref="BikeGroupCol.Entry"/> objects. </summary>
|
||||
/// <remarks> Each entry has a name, holds the count of available bikes at station and the group value. /// </remarks>
|
||||
IBikeGroupCol BikeGroups { get; }
|
||||
|
||||
}
|
||||
}
|
35
SharedBusinessLogic/Model/Stations/StationNS/NullStation.cs
Normal file
35
SharedBusinessLogic/Model/Stations/StationNS/NullStation.cs
Normal file
|
@ -0,0 +1,35 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ShareeBike.Model.Stations.StationNS.Operator;
|
||||
|
||||
namespace ShareeBike.Model.Stations.StationNS
|
||||
{
|
||||
/// <summary> Holds object representing null station.</summary>
|
||||
public class NullStation : IStation
|
||||
{
|
||||
/// <summary> Holds the unique id of the station.c</summary>
|
||||
public string Id => null;
|
||||
|
||||
/// <summary> Holds the group to which the station belongs.</summary>
|
||||
public IEnumerable<string> Group => new List<string>();
|
||||
|
||||
/// <summary> Gets the name of the station.</summary>
|
||||
public string StationName => string.Empty;
|
||||
|
||||
/// <summary> Uri of the operator or null. </summary>
|
||||
public Uri OperatorUri => null;
|
||||
|
||||
/// <summary> Holds the gps- position of the station.</summary>
|
||||
public IPosition Position => PositionFactory.Create();
|
||||
|
||||
/// <summary> Holds operator related data.</summary>
|
||||
public IData OperatorData => new Data();
|
||||
|
||||
/// <summary> Gets the count of bikes available at station. </summary>
|
||||
public int? AvailableBikesCount => null;
|
||||
|
||||
/// <summary> Gets bike <see cref="BikeGroupCol.Entry"/> objects. </summary>
|
||||
/// <remarks> Each entry has a name, holds the count of available bikes at station and the group value. /// </remarks>
|
||||
public IBikeGroupCol BikeGroups => null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace ShareeBike.Model.Stations.StationNS.Operator
|
||||
{
|
||||
public class BikeGroupCol : List<BikeGroupCol.Entry> , IBikeGroupCol
|
||||
{
|
||||
/// <summary>
|
||||
/// Holds a group of bikes at a station.
|
||||
/// </summary>
|
||||
public class Entry
|
||||
{
|
||||
/// <summary>
|
||||
/// Bike group entry.
|
||||
/// </summary>
|
||||
/// <param name="name">Name of the group, either "Citybikes" or "Cargobikes".</param>
|
||||
/// <param name="availableCount"></param>
|
||||
/// <param name="group"></param>
|
||||
public Entry(string name, int? availableCount = null, string group = null)
|
||||
{
|
||||
Name = name;
|
||||
AvailableCount = availableCount ?? 0;
|
||||
Group = group ?? string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Name of the group, either "Citybikes" or "Cargobikes".
|
||||
/// </summary>
|
||||
public string Name { get; }
|
||||
|
||||
/// <summary> Holds the count of bikes available of given type at station. </summary>
|
||||
public int AvailableCount { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Holds the group of the bikes. Citybike separates cargo and city bikes by group.
|
||||
/// </summary>
|
||||
public string Group { get; }
|
||||
}
|
||||
|
||||
public BikeGroupCol() : base() { }
|
||||
|
||||
public BikeGroupCol(IEnumerable<Entry> source) : base(source) { }
|
||||
|
||||
/// <summary> Holds the count of bikes available of any type at station. </summary>
|
||||
public int AvailableCount => this.Select(x => x.AvailableCount).Sum();
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
using Xamarin.Forms;
|
||||
|
||||
namespace ShareeBike.Model.Stations.StationNS.Operator
|
||||
{
|
||||
/// <summary> Holds operator related data.</summary>
|
||||
public class Data : IData
|
||||
{
|
||||
public Data(
|
||||
string name = null,
|
||||
string phoneNumberText = null,
|
||||
string hours = null,
|
||||
string mailAddressText = null, Color? color = null)
|
||||
{
|
||||
Name = name ?? string.Empty;
|
||||
PhoneNumberText = phoneNumberText ?? string.Empty;
|
||||
Hours = hours ?? string.Empty;
|
||||
MailAddressText = mailAddressText ?? string.Empty;
|
||||
Color = color;
|
||||
}
|
||||
|
||||
/// <summary> Name of the operator.</summary>
|
||||
public string Name { get; private set; }
|
||||
|
||||
/// <summary> Support phone number of the operator.</summary>
|
||||
public string PhoneNumberText { get; private set; }
|
||||
|
||||
/// <summary> Office times when support is available.</summary>
|
||||
public string Hours { get; private set; }
|
||||
|
||||
/// <summary> Support mails address of the operator.</summary>
|
||||
public string MailAddressText { get; private set; }
|
||||
|
||||
/// <summary> Color of the operator (operator specific skin)</summary>
|
||||
public Color? Color { get; private set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace ShareeBike.Model.Stations.StationNS.Operator
|
||||
{
|
||||
public interface IBikeGroupCol : IEnumerable<BikeGroupCol.Entry>
|
||||
{
|
||||
/// <summary> Holds the count of bikes available of given type at station. </summary>
|
||||
int AvailableCount { get; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
using Xamarin.Forms;
|
||||
|
||||
namespace ShareeBike.Model.Stations.StationNS.Operator
|
||||
{
|
||||
public interface IData
|
||||
{
|
||||
/// <summary> Name of the operator.</summary>
|
||||
string Name { get; }
|
||||
|
||||
/// <summary> Support phone number of the operator.</summary>
|
||||
string PhoneNumberText { get; }
|
||||
|
||||
/// <summary> Office times when support is available.</summary>
|
||||
string Hours { get; }
|
||||
|
||||
/// <summary> Support mails address of the operator.</summary>
|
||||
string MailAddressText { get; }
|
||||
|
||||
/// <summary> Color of the operator (operator specific skin)</summary>
|
||||
Color? Color { get; }
|
||||
}
|
||||
}
|
59
SharedBusinessLogic/Model/Stations/StationNS/Station.cs
Normal file
59
SharedBusinessLogic/Model/Stations/StationNS/Station.cs
Normal file
|
@ -0,0 +1,59 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ShareeBike.Model.Stations.StationNS.Operator;
|
||||
|
||||
namespace ShareeBike.Model.Stations.StationNS
|
||||
{
|
||||
/// <summary> Holds station info. </summary>
|
||||
public class Station : IStation
|
||||
{
|
||||
/// <summary> Constructs a station object.</summary>
|
||||
/// <param name="id">Id of the station.</param>
|
||||
/// <param name="group">Group (ShareeBike, Citybike) to which station is related.</param>
|
||||
/// <param name="position">GPS- position of the station.</param>
|
||||
/// <param name="stationName">Name of the station.</param>
|
||||
/// <param name="operatorUri">Uri of the operator or null.</param>
|
||||
public Station(
|
||||
string id,
|
||||
IEnumerable<string> group = null,
|
||||
IPosition position = null,
|
||||
string stationName = "",
|
||||
Uri operatorUri = null,
|
||||
IData operatorData = null,
|
||||
IBikeGroupCol bikeGropCol = null)
|
||||
{
|
||||
Id = id;
|
||||
Group = group ?? throw new ArgumentException("Can not construct station object. Group of stations must not be null.");
|
||||
Position = position;
|
||||
StationName = stationName ?? string.Empty;
|
||||
OperatorData = operatorData ?? new Data();
|
||||
BikeGroups = bikeGropCol ?? new BikeGroupCol();
|
||||
OperatorUri = operatorUri;
|
||||
}
|
||||
|
||||
/// <summary> Holds the unique id of the station.c</summary>
|
||||
public string Id { get; }
|
||||
|
||||
/// <summary> Holds the group to which the station belongs.</summary>
|
||||
public IEnumerable<string> Group { get; }
|
||||
|
||||
/// <summary> Gets the name of the station.</summary>
|
||||
public string StationName { get; }
|
||||
|
||||
/// <summary> Holds the gps- position of the station.</summary>
|
||||
public IPosition Position { get; }
|
||||
|
||||
/// <summary> Holds operator related info.</summary>
|
||||
public IData OperatorData { get; }
|
||||
|
||||
/// <summary> Gets the count of bikes available at station. </summary>
|
||||
public int? AvailableBikesCount => BikeGroups.AvailableCount;
|
||||
|
||||
/// <summary> Gets bike <see cref="BikeGroupCol.Entry"/> objects. </summary>
|
||||
/// <remarks> Each entry has a name, holds the count of available bikes at station and the group value. /// </remarks>
|
||||
public IBikeGroupCol BikeGroups { get; }
|
||||
|
||||
/// <summary> Uri of the operator or null. </summary>
|
||||
public Uri OperatorUri { get; }
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue