mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-06-22 05:47:28 +02:00
Version 3.0.363
This commit is contained in:
parent
4ff3307997
commit
91d42552c7
212 changed files with 1799 additions and 1318 deletions
98
TINKLib/Model/Stations/StationCollection.cs
Normal file
98
TINKLib/Model/Stations/StationCollection.cs
Normal file
|
@ -0,0 +1,98 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TINK.Model.Stations.StationNS;
|
||||
|
||||
namespace TINK.Model.Stations
|
||||
{
|
||||
public class StationDictionary : IEnumerable<IStation>
|
||||
{
|
||||
/// <summary> Holds the list of stations. </summary>
|
||||
private readonly IDictionary<string, IStation> m_oStationDictionary;
|
||||
|
||||
/// <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="p_oVersion">Version of copri- service.</param>
|
||||
public StationDictionary(Version p_oVersion = null, IDictionary<string, IStation> p_oStations = null)
|
||||
{
|
||||
m_oStationDictionary = p_oStations ?? new Dictionary<string, IStation>();
|
||||
|
||||
CopriVersion = p_oVersion != null
|
||||
? new Version(p_oVersion.Major, p_oVersion.Minor, p_oVersion.Revision, p_oVersion.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();
|
||||
}
|
||||
}
|
||||
}
|
23
TINKLib/Model/Stations/StationNS/IStation.cs
Normal file
23
TINKLib/Model/Stations/StationNS/IStation.cs
Normal file
|
@ -0,0 +1,23 @@
|
|||
using System.Collections.Generic;
|
||||
using TINK.Model.Stations.StationNS.Operator;
|
||||
|
||||
namespace TINK.Model.Stations.StationNS
|
||||
{
|
||||
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> Holds the gps- position of the station.</summary>
|
||||
IPosition Position { get; }
|
||||
|
||||
/// <summary> Holds operator related data.</summary>
|
||||
IData OperatorData { get; }
|
||||
}
|
||||
}
|
24
TINKLib/Model/Stations/StationNS/NullStation.cs
Normal file
24
TINKLib/Model/Stations/StationNS/NullStation.cs
Normal file
|
@ -0,0 +1,24 @@
|
|||
using System.Collections.Generic;
|
||||
using TINK.Model.Stations.StationNS.Operator;
|
||||
|
||||
namespace TINK.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> Holds the gps- position of the station.</summary>
|
||||
public IPosition Position => PositionFactory.Create();
|
||||
|
||||
/// <summary> Holds operator related data.</summary>
|
||||
public IData OperatorData => new Data();
|
||||
}
|
||||
}
|
36
TINKLib/Model/Stations/StationNS/Operator/Data.cs
Normal file
36
TINKLib/Model/Stations/StationNS/Operator/Data.cs
Normal file
|
@ -0,0 +1,36 @@
|
|||
using Xamarin.Forms;
|
||||
|
||||
namespace TINK.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; }
|
||||
}
|
||||
}
|
22
TINKLib/Model/Stations/StationNS/Operator/IData.cs
Normal file
22
TINKLib/Model/Stations/StationNS/Operator/IData.cs
Normal file
|
@ -0,0 +1,22 @@
|
|||
using Xamarin.Forms;
|
||||
|
||||
namespace TINK.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; }
|
||||
}
|
||||
}
|
44
TINKLib/Model/Stations/StationNS/Station.cs
Normal file
44
TINKLib/Model/Stations/StationNS/Station.cs
Normal file
|
@ -0,0 +1,44 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TINK.Model.Stations.StationNS.Operator;
|
||||
|
||||
namespace TINK.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 (TINK, Konrad) to which station is related.</param>
|
||||
/// <param name="position">GPS- position of the station.</param>
|
||||
/// <param name="stationName">Name of the station.</param>
|
||||
public Station(
|
||||
string id,
|
||||
IEnumerable<string> group,
|
||||
IPosition position,
|
||||
string stationName = "",
|
||||
Data operatorData = 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();
|
||||
}
|
||||
|
||||
/// <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; }
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue