mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-04-20 12:06:29 +02:00
Initial version.
This commit is contained in:
parent
193aaa1a56
commit
b72c67a53e
228 changed files with 25924 additions and 0 deletions
216
TINKLib/Model/Bikes/Bike/BC/BikeInfo.cs
Normal file
216
TINKLib/Model/Bikes/Bike/BC/BikeInfo.cs
Normal file
|
@ -0,0 +1,216 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TINK.Model.Bikes.Bike;
|
||||
using TINK.Model.State;
|
||||
|
||||
namespace TINK.Model.Bike.BC
|
||||
{
|
||||
public class BikeInfo : IBikeInfo
|
||||
{
|
||||
/// <summary> Default value of demo property. </summary>
|
||||
public const bool DEFAULTVALUEISDEMO = false;
|
||||
|
||||
/// <summary> Holds the info about the bike state. </summary>
|
||||
private readonly IStateInfo m_oStateInfo;
|
||||
|
||||
/// <summary>
|
||||
/// Holds the bike object.
|
||||
/// </summary>
|
||||
private Bike Bike { get; }
|
||||
|
||||
/// <summary> Constructs a bike object.</summary>
|
||||
protected BikeInfo(
|
||||
IStateInfo stateInfo,
|
||||
int id,
|
||||
bool? isDemo = DEFAULTVALUEISDEMO,
|
||||
IEnumerable<string> group = null,
|
||||
WheelType? wheelType = null,
|
||||
TypeOfBike? typeOfBike = null,
|
||||
string description = null,
|
||||
int? currentStationId = null,
|
||||
Uri operatorUri = null,
|
||||
TariffDescription tariffDescription = null)
|
||||
{
|
||||
Bike = new Bike(id, wheelType, typeOfBike, description);
|
||||
|
||||
m_oStateInfo = stateInfo;
|
||||
|
||||
IsDemo = isDemo ?? DEFAULTVALUEISDEMO;
|
||||
Group = group ?? new List<string>();
|
||||
CurrentStation = currentStationId;
|
||||
OperatorUri = operatorUri;
|
||||
TariffDescription = tariffDescription;
|
||||
}
|
||||
|
||||
public BikeInfo(BikeInfo bikeInfo) : this(
|
||||
bikeInfo?.State,
|
||||
bikeInfo?.Id ?? throw new ArgumentException($"Can not copy-construct {typeof(BikeInfo).Name}-object. Source must not be null."),
|
||||
bikeInfo.IsDemo,
|
||||
bikeInfo.Group,
|
||||
bikeInfo.WheelType,
|
||||
bikeInfo.TypeOfBike,
|
||||
bikeInfo.Description,
|
||||
bikeInfo.CurrentStation,
|
||||
bikeInfo.OperatorUri,
|
||||
bikeInfo.TariffDescription) { }
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a bike info object for a available bike.
|
||||
/// </summary>
|
||||
/// <param name="id">Unique id of bike.</param>
|
||||
/// <param name="currentStationId">Id of station where bike is located.</param>
|
||||
/// <param name="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param>
|
||||
/// <param name="tariffDescription">Hold tariff description of bike.</param>
|
||||
/// <param name="wheelType"></param>
|
||||
public BikeInfo(
|
||||
int id,
|
||||
int? currentStationId,
|
||||
Uri operatorUri = null,
|
||||
TariffDescription tariffDescription = null,
|
||||
bool? isDemo = DEFAULTVALUEISDEMO,
|
||||
IEnumerable<string> group = null,
|
||||
WheelType? wheelType = null,
|
||||
TypeOfBike? typeOfBike = null,
|
||||
string description = null) : this(
|
||||
new StateInfo(),
|
||||
id,
|
||||
isDemo,
|
||||
group,
|
||||
wheelType,
|
||||
typeOfBike,
|
||||
description,
|
||||
currentStationId,
|
||||
operatorUri,
|
||||
tariffDescription)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a bike info object for a requested bike.
|
||||
/// </summary>
|
||||
/// <param name="dateTimeProvider">Provider for current date time to calculate remainig time on demand for state of type reserved.</param>
|
||||
/// <param name="wheelType"></param>
|
||||
/// <param name="id">Unique id of bike.</param>
|
||||
/// <param name="stationId">Name of station where bike is located, null if bike is on the road.</param>
|
||||
/// <param name="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param>
|
||||
/// <param name="tariffDescription">Hold tariff description of bike.</param>
|
||||
/// <param name="requestedAt">Date time when bike was requested</param>
|
||||
/// <param name="mailAddress">Mail address of user which requested bike.</param>
|
||||
/// <param name="code">Booking code.</param>
|
||||
/// <param name="p_oDateTimeNowProvider">Date time provider to calculate reaining time.</param>
|
||||
public BikeInfo(
|
||||
int id,
|
||||
bool? isDemo,
|
||||
IEnumerable<string> group,
|
||||
WheelType? wheelType,
|
||||
TypeOfBike? typeOfBike,
|
||||
string description,
|
||||
int? stationId,
|
||||
Uri operatorUri,
|
||||
TariffDescription tariffDescription,
|
||||
DateTime requestedAt,
|
||||
string mailAddress,
|
||||
string code,
|
||||
Func<DateTime> dateTimeProvider = null) : this(
|
||||
new StateInfo(
|
||||
dateTimeProvider,
|
||||
requestedAt,
|
||||
mailAddress,
|
||||
code),
|
||||
id,
|
||||
isDemo,
|
||||
group,
|
||||
wheelType,
|
||||
typeOfBike,
|
||||
description,
|
||||
stationId,
|
||||
operatorUri,
|
||||
tariffDescription)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a bike info object for a booked bike.
|
||||
/// </summary>
|
||||
/// <param name="dateTimeProvider">Provider for current date time to calculate remainig time on demand for state of type reserved.</param>
|
||||
/// <param name="wheelType"></param>
|
||||
/// <param name="id">Unique id of bike.</param>
|
||||
/// <param name="currentStationId">Name of station where bike is located, null if bike is on the road.</param>
|
||||
/// <param name="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param>
|
||||
/// <param name="tariffDescription">Hold tariff description of bike.</param>
|
||||
/// <param name="bookedAt">Date time when bike was booked</param>
|
||||
/// <param name="mailAddress">Mail address of user which booked bike.</param>
|
||||
/// <param name="code">Booking code.</param>
|
||||
public BikeInfo(
|
||||
int id,
|
||||
bool? isDemo,
|
||||
IEnumerable<string> group,
|
||||
WheelType? wheelType,
|
||||
TypeOfBike? typeOfBike,
|
||||
string description,
|
||||
int? currentStationId,
|
||||
Uri operatorUri,
|
||||
TariffDescription tariffDescription,
|
||||
DateTime bookedAt,
|
||||
string mailAddress,
|
||||
string code) : this(
|
||||
new StateInfo(
|
||||
bookedAt,
|
||||
mailAddress,
|
||||
code),
|
||||
id,
|
||||
isDemo,
|
||||
group,
|
||||
wheelType,
|
||||
typeOfBike,
|
||||
description,
|
||||
currentStationId,
|
||||
operatorUri,
|
||||
tariffDescription)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary> True if device is demo device, false otherwise. </summary>
|
||||
public bool IsDemo { get; }
|
||||
|
||||
/// <summary> Returns the group (TINK, Konrad, ...). </summary>
|
||||
public IEnumerable<string> Group { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Station a which bike is located, null otherwise.
|
||||
/// </summary>
|
||||
public int? CurrentStation { get; }
|
||||
|
||||
/// <summary> Holds description about the tarif. </summary>
|
||||
public TariffDescription TariffDescription { get; }
|
||||
|
||||
|
||||
/// Holds the rent state of the bike.
|
||||
/// </summary>
|
||||
public IStateInfo State
|
||||
{
|
||||
get { return m_oStateInfo; }
|
||||
}
|
||||
|
||||
public int Id => Bike.Id;
|
||||
|
||||
public WheelType? WheelType => Bike.WheelType;
|
||||
|
||||
public TypeOfBike? TypeOfBike => Bike.TypeOfBike;
|
||||
|
||||
public string Description => Bike.Description;
|
||||
|
||||
/// <summary>
|
||||
/// Uri of the operator or null, in case of single operator setup.
|
||||
/// </summary>
|
||||
public Uri OperatorUri { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Converts the instance to text.
|
||||
/// </summary>
|
||||
public new string ToString()
|
||||
{
|
||||
return $"Id={Bike.Id}{(Bike.WheelType != null ? $", wheel(s)={Bike.WheelType}" : string.Empty)}{(Bike.TypeOfBike != null ? $"type={Bike.TypeOfBike}" : "")}, state={State}, location={(CurrentStation.HasValue ? $"Station {CurrentStation}" : "On the road")}, is demo={IsDemo}.";
|
||||
}
|
||||
}
|
||||
}
|
124
TINKLib/Model/Bikes/Bike/BC/BikeInfoMutable.cs
Normal file
124
TINKLib/Model/Bikes/Bike/BC/BikeInfoMutable.cs
Normal file
|
@ -0,0 +1,124 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.Serialization;
|
||||
using TINK.Model.Bikes.Bike;
|
||||
using TINK.Model.Bikes.Bike.BC;
|
||||
using TINK.Model.State;
|
||||
|
||||
namespace TINK.Model.Bike.BC
|
||||
{
|
||||
[DataContract]
|
||||
public class BikeInfoMutable : IBikeInfoMutable, INotifyPropertyChanged
|
||||
{
|
||||
/// <summary> Holds the bike. </summary>
|
||||
private readonly Bike m_oBike;
|
||||
|
||||
/// <summary> Holds the state info of the bike. </summary>
|
||||
private readonly StateInfoMutable m_oStateInfo;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a bike.
|
||||
/// </summary>
|
||||
/// <param name="id">Unique id of bike.</param>
|
||||
/// <param name="isDemo">True if device is demo device, false otherwise.</param>
|
||||
/// <param name="dateTimeProvider">Provider for current date time to calculate remainig time on demand for state of type reserved.</param>
|
||||
/// <param name="wheelType"></param>
|
||||
/// <param name="currentStationId">Name of station where bike is located, null if bike is on the road.</param>
|
||||
/// <param name="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param>
|
||||
/// <param name="tariffDescription">Hold tariff description of bike.</param>
|
||||
/// <param name="stateInfo">Bike state info.</param>
|
||||
protected BikeInfoMutable(
|
||||
int id,
|
||||
bool isDemo = BikeInfo.DEFAULTVALUEISDEMO,
|
||||
IEnumerable<string> group = null,
|
||||
WheelType? wheelType = null,
|
||||
TypeOfBike? typeOfBike = null,
|
||||
string description = null,
|
||||
int? currentStationId = null,
|
||||
Uri operatorUri = null,
|
||||
TariffDescription tariffDescription = null,
|
||||
Func<DateTime> dateTimeProvider = null,
|
||||
IStateInfo stateInfo = null)
|
||||
{
|
||||
IsDemo = isDemo;
|
||||
Group = group;
|
||||
m_oBike = new Bike(id, wheelType, typeOfBike, description);
|
||||
m_oStateInfo = new StateInfoMutable(dateTimeProvider, stateInfo);
|
||||
m_oStateInfo.PropertyChanged += (sender, eventargs) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(eventargs.PropertyName));
|
||||
CurrentStation = currentStationId;
|
||||
OperatorUri = operatorUri;
|
||||
TariffDescription = tariffDescription;
|
||||
}
|
||||
|
||||
/// <summary> Constructs a bike object from source. </summary>
|
||||
public BikeInfoMutable(IBikeInfo p_oBike) : this(
|
||||
p_oBike.Id,
|
||||
p_oBike.IsDemo,
|
||||
p_oBike.Group,
|
||||
p_oBike.WheelType,
|
||||
p_oBike.TypeOfBike,
|
||||
p_oBike.Description,
|
||||
p_oBike.CurrentStation,
|
||||
p_oBike.OperatorUri,
|
||||
p_oBike.TariffDescription,
|
||||
null,
|
||||
p_oBike.State)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Station a which bike is located, null otherwise.
|
||||
/// </summary>
|
||||
[DataMember]
|
||||
public int? CurrentStation { get; }
|
||||
|
||||
/// <summary> Holds description about the tarif. </summary>
|
||||
[DataMember]
|
||||
public TariffDescription TariffDescription { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Holds the rent state of the bike.
|
||||
/// </summary>
|
||||
[DataMember]
|
||||
public StateInfoMutable State
|
||||
{
|
||||
get { return m_oStateInfo; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Uri of the operator or null, in case of single operator setup.
|
||||
/// </summary>
|
||||
public Uri OperatorUri { get; }
|
||||
|
||||
/// <summary> Unused member. </summary>
|
||||
IStateInfoMutable IBikeInfoMutable.State => m_oStateInfo;
|
||||
|
||||
public int Id => m_oBike.Id;
|
||||
|
||||
public bool IsDemo { get; }
|
||||
|
||||
/// <summary> Returns the group (TINK, Konrad, ...). </summary>
|
||||
public IEnumerable<string> Group { get; }
|
||||
|
||||
public WheelType? WheelType => m_oBike.WheelType;
|
||||
|
||||
public TypeOfBike? TypeOfBike => m_oBike.TypeOfBike;
|
||||
|
||||
public string Description => m_oBike.Description;
|
||||
|
||||
/// <summary>
|
||||
/// Fired whenever property of bike changes.
|
||||
/// </summary>
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Converts the instance to text.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public new string ToString()
|
||||
{
|
||||
return $"Id={Id}{(WheelType != null ? $", wheel(s)={WheelType}" : string.Empty)}{(TypeOfBike != null ? $", type={TypeOfBike}" : "")}, demo={IsDemo}, state={State.ToString()}, location={(CurrentStation.HasValue ? $"Station {CurrentStation}" : "On the road")}.";
|
||||
}
|
||||
}
|
||||
}
|
55
TINKLib/Model/Bikes/Bike/BC/IBikeInfo.cs
Normal file
55
TINKLib/Model/Bikes/Bike/BC/IBikeInfo.cs
Normal file
|
@ -0,0 +1,55 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TINK.Model.Bikes.Bike;
|
||||
using TINK.Model.State;
|
||||
|
||||
namespace TINK.Model.Bike.BC
|
||||
{
|
||||
/// <summary>
|
||||
/// Allows to access bike info.
|
||||
/// </summary>
|
||||
public interface IBikeInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Holds the unique id of the bike;
|
||||
/// </summary>
|
||||
int Id { get; }
|
||||
|
||||
/// <summary> True if bike is a demo bike. </summary>
|
||||
bool IsDemo { get; }
|
||||
|
||||
/// <summary> Returns the group (TINK, Konrad, ...). </summary>
|
||||
IEnumerable<string> Group { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Holds the count of wheels.
|
||||
/// </summary>
|
||||
WheelType? WheelType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Holds the type of bike.
|
||||
/// </summary>
|
||||
TypeOfBike? TypeOfBike { get; }
|
||||
|
||||
/// <summary> Holds the description of the bike. </summary>
|
||||
string Description { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Station a which bike is located, null otherwise.
|
||||
/// </summary>
|
||||
int? CurrentStation { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Uri of the operator or null, in case of single operator setup.
|
||||
/// </summary>
|
||||
Uri OperatorUri { get; }
|
||||
|
||||
/// <summary> Holds description about the tarif. </summary>
|
||||
TariffDescription TariffDescription { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Holds the rent state of the bike.
|
||||
/// </summary>
|
||||
IStateInfo State { get; }
|
||||
}
|
||||
}
|
61
TINKLib/Model/Bikes/Bike/BC/IBikeInfoMutable.cs
Normal file
61
TINKLib/Model/Bikes/Bike/BC/IBikeInfoMutable.cs
Normal file
|
@ -0,0 +1,61 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using TINK.Model.Bike;
|
||||
using TINK.Model.State;
|
||||
|
||||
namespace TINK.Model.Bikes.Bike.BC
|
||||
{
|
||||
public interface IBikeInfoMutable
|
||||
{
|
||||
/// <summary>
|
||||
/// Holds the unique id of the bike;
|
||||
/// </summary>
|
||||
int Id { get; }
|
||||
|
||||
/// <summary> True if bike is a demo bike. </summary>
|
||||
bool IsDemo { get; }
|
||||
|
||||
/// <summary> Returns the group (TINK, Konrad, ...). </summary>
|
||||
IEnumerable<string> Group { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Holds the count of wheels.
|
||||
/// </summary>
|
||||
WheelType? WheelType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Holds the type of bike.
|
||||
/// </summary>
|
||||
TypeOfBike? TypeOfBike { get; }
|
||||
|
||||
/// <summary> Holds the description of the bike. </summary>
|
||||
string Description { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Station a which bike is located, null otherwise.
|
||||
/// </summary>
|
||||
int? CurrentStation { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Holds the rent state of the bike.
|
||||
/// </summary>
|
||||
IStateInfoMutable State { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Uri of the operator or null, in case of single operator setup.
|
||||
/// </summary>
|
||||
Uri OperatorUri { get; }
|
||||
|
||||
event PropertyChangedEventHandler PropertyChanged;
|
||||
}
|
||||
|
||||
public enum NotifyPropertyChangedLevel
|
||||
{
|
||||
/// <summary> Notify about all property changes.</summary>
|
||||
All,
|
||||
|
||||
/// <summary> Notify about no property changes.</summary>
|
||||
None
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue