using System;
using System.Collections.Generic;
using ShareeBike.Model.Bikes.BikeInfoNS.BikeNS;
using ShareeBike.Model.Bikes.BikeInfoNS.DriveNS;
using ShareeBike.Model.State;
namespace ShareeBike.Model.Bikes.BikeInfoNS.BC
{
public abstract class BikeInfo : IBikeInfo
{
/// Default value of demo property.
public const bool DEFAULTVALUEISDEMO = false;
/// Holds the info about the bike state.
private readonly IStateInfo _StateInfo;
///
/// Holds the bike object.
///
public Bike Bike { get; }
///
/// Holds the drive object.
///
public DriveMutable Drive { get; }
/// Gets the information where the data origins from.
public DataSource DataSource { get; }
/// Constructs a bike object.
/// Specified the source of the data.
protected BikeInfo(
IStateInfo stateInfo,
Bike bike,
DriveMutable drive,
DataSource dataSource,
bool? isDemo = DEFAULTVALUEISDEMO,
IEnumerable 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();
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)
{ }
/// True if device is demo device, false otherwise.
public bool IsDemo { get; }
/// Returns the group (ShareeBike, Citybike, ...).
public IEnumerable Group { get; }
///
/// Station a which bike is located, null otherwise.
///
public string StationId { get; }
/// Holds description about the tariff.
public RentalDescription TariffDescription { get; }
/// Holds the rent state of the bike.
///
public IStateInfo State
{
get { return _StateInfo; }
}
public string Id => Bike.Id;
public WheelType? WheelType => Bike.WheelType;
public TypeOfBike? TypeOfBike => Bike.TypeOfBike;
/// Gets the model of the lock.
public LockModel LockModel => Bike.LockModel;
public string Description => Bike.Description;
///
/// Uri of the operator or null, in case of single operator setup.
///
public Uri OperatorUri { get; }
///
/// Converts the instance to text.
///
public override 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}.";
}
}
}