mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2024-11-16 23:26:26 +01:00
112 lines
3.2 KiB
C#
112 lines
3.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using TINK.Model.Bikes.BikeInfoNS.BikeNS;
|
|
using TINK.Model.Bikes.BikeInfoNS.DriveNS;
|
|
using TINK.Model.State;
|
|
|
|
namespace TINK.Model.Bikes.BikeInfoNS.BC
|
|
{
|
|
public abstract 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 _StateInfo;
|
|
|
|
/// <summary>
|
|
/// Holds the bike object.
|
|
/// </summary>
|
|
public Bike Bike { get; }
|
|
|
|
/// <summary>
|
|
/// Holds the drive object.
|
|
/// </summary>
|
|
public DriveMutable Drive { get; }
|
|
|
|
/// <summary> Gets the information where the data origins from. </summary>
|
|
public DataSource DataSource { get; }
|
|
|
|
/// <summary> Constructs a bike object.</summary>
|
|
/// <param name="dataSource">Specified the source of the data.</param>
|
|
protected BikeInfo(
|
|
IStateInfo stateInfo,
|
|
Bike bike,
|
|
DriveMutable drive,
|
|
DataSource dataSource,
|
|
bool? isDemo = DEFAULTVALUEISDEMO,
|
|
IEnumerable<string> group = null,
|
|
string stationId = null,
|
|
Uri operatorUri = null,
|
|
RentalDescription tariffDescription = null)
|
|
{
|
|
Bike = bike ?? throw new ArgumentNullException(nameof(bike));
|
|
Drive = drive ?? throw new ArgumentNullException(nameof(drive));
|
|
DataSource = dataSource;
|
|
_StateInfo = stateInfo;
|
|
|
|
IsDemo = isDemo ?? DEFAULTVALUEISDEMO;
|
|
Group = group ?? new List<string>();
|
|
StationId = stationId;
|
|
OperatorUri = operatorUri;
|
|
TariffDescription = tariffDescription;
|
|
}
|
|
|
|
public BikeInfo(BikeInfo bikeInfo) : this(
|
|
bikeInfo != null ? bikeInfo?.State : throw new ArgumentNullException(nameof(bikeInfo)),
|
|
bikeInfo.Bike,
|
|
bikeInfo.Drive,
|
|
bikeInfo.DataSource,
|
|
bikeInfo.IsDemo,
|
|
bikeInfo.Group,
|
|
bikeInfo.StationId,
|
|
bikeInfo.OperatorUri,
|
|
bikeInfo.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 string StationId { get; }
|
|
|
|
/// <summary> Holds description about the tariff. </summary>
|
|
public RentalDescription TariffDescription { get; }
|
|
|
|
/// Holds the rent state of the bike.
|
|
/// </summary>
|
|
public IStateInfo State
|
|
{
|
|
get { return _StateInfo; }
|
|
}
|
|
|
|
public string Id => Bike.Id;
|
|
|
|
public WheelType? WheelType => Bike.WheelType;
|
|
|
|
public TypeOfBike? TypeOfBike => Bike.TypeOfBike;
|
|
|
|
/// <summary> Gets the model of the lock. </summary>
|
|
public LockModel LockModel => Bike.LockModel;
|
|
|
|
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={(!string.IsNullOrEmpty(StationId) ? $"Station {StationId}" : "On the road")}, is demo={IsDemo}.";
|
|
}
|
|
}
|
|
}
|