Version 3.0.338

This commit is contained in:
Anja Müller-Meißner 2022-09-06 16:08:19 +02:00 committed by Anja
parent 573fe77e12
commit 0468955d49
751 changed files with 62747 additions and 60672 deletions

View file

@ -6,161 +6,161 @@ using TINK.Model.State;
namespace TINK.Model.Bikes.BikeInfoNS.BC
{
public class BikeInfo : IBikeInfo
{
/// <summary> Default value of demo property. </summary>
public const bool DEFAULTVALUEISDEMO = false;
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 _StateInfo;
/// <summary> Holds the info about the bike state. </summary>
private readonly IStateInfo _StateInfo;
/// <summary>
/// Holds the bike object.
/// </summary>
public BikeNS.Bike Bike { get; }
/// <summary>
/// Holds the bike object.
/// </summary>
public BikeNS.Bike Bike { get; }
/// <summary>
/// Holds the drive object.
/// </summary>
public Drive Drive { get; }
/// <summary>
/// Holds the drive object.
/// </summary>
public Drive Drive { get; }
/// <summary> Constructs a bike object.</summary>
protected BikeInfo(
IStateInfo stateInfo,
BikeNS.Bike bike,
Drive drive,
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));
_StateInfo = stateInfo;
/// <summary> Constructs a bike object.</summary>
protected BikeInfo(
IStateInfo stateInfo,
BikeNS.Bike bike,
Drive drive,
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));
_StateInfo = stateInfo;
IsDemo = isDemo ?? DEFAULTVALUEISDEMO;
Group = group ?? new List<string>();
StationId = stationId;
OperatorUri = operatorUri;
TariffDescription = tariffDescription;
}
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.IsDemo,
bikeInfo.Group,
bikeInfo.StationId,
bikeInfo.OperatorUri,
bikeInfo.TariffDescription)
{ }
public BikeInfo(BikeInfo bikeInfo) : this(
bikeInfo != null ? bikeInfo?.State : throw new ArgumentNullException(nameof(bikeInfo)),
bikeInfo.Bike,
bikeInfo.Drive,
bikeInfo.IsDemo,
bikeInfo.Group,
bikeInfo.StationId,
bikeInfo.OperatorUri,
bikeInfo.TariffDescription)
{ }
/// <summary>
/// Constructs a bike info object for a available bike.
/// </summary>
/// <param name="stationId">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>
public BikeInfo(
BikeNS.Bike bike,
Drive drive,
string stationId,
Uri operatorUri = null,
RentalDescription tariffDescription = null,
bool? isDemo = DEFAULTVALUEISDEMO,
IEnumerable<string> group = null) : this(
new StateInfo(),
bike,
drive,
isDemo,
group,
stationId,
operatorUri,
tariffDescription)
{
}
/// <summary>
/// Constructs a bike info object for a available bike.
/// </summary>
/// <param name="stationId">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>
public BikeInfo(
BikeNS.Bike bike,
Drive drive,
string stationId,
Uri operatorUri = null,
RentalDescription tariffDescription = null,
bool? isDemo = DEFAULTVALUEISDEMO,
IEnumerable<string> group = null) : this(
new StateInfo(),
bike,
drive,
isDemo,
group,
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="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(
BikeNS.Bike bike,
Drive drive,
bool? isDemo,
IEnumerable<string> group,
string currentStationId,
Uri operatorUri,
RentalDescription tariffDescription,
DateTime bookedAt,
string mailAddress,
string code) : this(
new StateInfo(
bookedAt,
mailAddress,
code),
bike,
drive,
isDemo,
group,
currentStationId,
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="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(
BikeNS.Bike bike,
Drive drive,
bool? isDemo,
IEnumerable<string> group,
string currentStationId,
Uri operatorUri,
RentalDescription tariffDescription,
DateTime bookedAt,
string mailAddress,
string code) : this(
new StateInfo(
bookedAt,
mailAddress,
code),
bike,
drive,
isDemo,
group,
currentStationId,
operatorUri,
tariffDescription)
{
}
/// <summary> True if device is demo device, false otherwise. </summary>
public bool IsDemo { get; }
/// <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> 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>
/// Station a which bike is located, null otherwise.
/// </summary>
public string StationId { get; }
/// <summary> Holds description about the tarif. </summary>
public RentalDescription TariffDescription { get; }
/// <summary> Holds description about the tarif. </summary>
public RentalDescription TariffDescription { get; }
/// Holds the rent state of the bike.
/// </summary>
public IStateInfo State
{
get { return _StateInfo; }
}
/// Holds the rent state of the bike.
/// </summary>
public IStateInfo State
{
get { return _StateInfo; }
}
public string Id => Bike.Id;
public string Id => Bike.Id;
public WheelType? WheelType => Bike.WheelType;
public WheelType? WheelType => Bike.WheelType;
public TypeOfBike? TypeOfBike => Bike.TypeOfBike;
public TypeOfBike? TypeOfBike => Bike.TypeOfBike;
/// <summary> Gets the model of the lock. </summary>
public LockModel LockModel => Bike.LockModel;
/// <summary> Gets the model of the lock. </summary>
public LockModel LockModel => Bike.LockModel;
public string Description => Bike.Description;
public string Description => Bike.Description;
/// <summary>
/// Uri of the operator or null, in case of single operator setup.
/// </summary>
public Uri OperatorUri { get; }
/// <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}.";
}
}
/// <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}.";
}
}
}

View file

@ -8,125 +8,125 @@ using TINK.Model.State;
namespace TINK.Model.Bikes.BikeInfoNS.BC
{
[DataContract]
public class BikeInfoMutable : IBikeInfoMutable, INotifyPropertyChanged
{
/// <summary> Holds the bike. </summary>
private readonly BikeNS.Bike _Bike;
[DataContract]
public class BikeInfoMutable : IBikeInfoMutable, INotifyPropertyChanged
{
/// <summary> Holds the bike. </summary>
private readonly BikeNS.Bike _Bike;
/// <summary> Holds the drive of the bike. </summary>
private readonly Drive _Drive;
/// <summary> Holds the drive of the bike. </summary>
private readonly Drive _Drive;
/// <summary> Holds the state info of the bike. </summary>
private readonly StateInfoMutable _StateInfo;
/// <summary> Holds the state info of the bike. </summary>
private readonly StateInfoMutable _StateInfo;
/// <summary>
/// Constructs a bike.
/// </summary>
/// <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="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="stateInfo">Bike state info.</param>
protected BikeInfoMutable(
BikeNS.Bike bike,
Drive drive,
bool isDemo = BikeInfo.DEFAULTVALUEISDEMO,
IEnumerable<string> group = null,
string stationId = null,
string stationName = null,
Uri operatorUri = null,
RentalDescription tariffDescription = null,
Func<DateTime> dateTimeProvider = null,
IStateInfo stateInfo = null)
{
IsDemo = isDemo;
Group = group;
_Bike = bike;
_Drive = drive;
_StateInfo = new StateInfoMutable(dateTimeProvider, stateInfo);
_StateInfo.PropertyChanged += (sender, eventargs) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(eventargs.PropertyName));
StationId = stationId;
StationName = stationName;
OperatorUri = operatorUri;
TariffDescription = tariffDescription;
}
/// <summary>
/// Constructs a bike.
/// </summary>
/// <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="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="stateInfo">Bike state info.</param>
protected BikeInfoMutable(
BikeNS.Bike bike,
Drive drive,
bool isDemo = BikeInfo.DEFAULTVALUEISDEMO,
IEnumerable<string> group = null,
string stationId = null,
string stationName = null,
Uri operatorUri = null,
RentalDescription tariffDescription = null,
Func<DateTime> dateTimeProvider = null,
IStateInfo stateInfo = null)
{
IsDemo = isDemo;
Group = group;
_Bike = bike;
_Drive = drive;
_StateInfo = new StateInfoMutable(dateTimeProvider, stateInfo);
_StateInfo.PropertyChanged += (sender, eventargs) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(eventargs.PropertyName));
StationId = stationId;
StationName = stationName;
OperatorUri = operatorUri;
TariffDescription = tariffDescription;
}
/// <summary> Constructs a bike object from source. </summary>
public BikeInfoMutable(IBikeInfo bike, string stationName) : this(
bike != null
? bike.Bike
: throw new ArgumentNullException(nameof(bike)),
bike.Drive,
bike.IsDemo,
bike.Group,
bike.StationId,
stationName,
bike.OperatorUri,
bike.TariffDescription,
null /* date time provider */,
bike.State)
{
}
/// <summary> Constructs a bike object from source. </summary>
public BikeInfoMutable(IBikeInfo bike, string stationName) : this(
bike != null
? bike.Bike
: throw new ArgumentNullException(nameof(bike)),
bike.Drive,
bike.IsDemo,
bike.Group,
bike.StationId,
stationName,
bike.OperatorUri,
bike.TariffDescription,
null /* date time provider */,
bike.State)
{
}
/// <summary> Id of station a which bike is located, null otherwise.</summary>
[DataMember]
public string StationId { get; }
/// <summary> Id of station a which bike is located, null otherwise.</summary>
[DataMember]
public string StationId { get; }
/// <summary> Name of station a which bike is located, null otherwise. </summary>
[DataMember]
public string StationName { get; }
/// <summary> Name of station a which bike is located, null otherwise. </summary>
[DataMember]
public string StationName { get; }
/// <summary> Holds description about the tarif. </summary>
[DataMember]
public RentalDescription TariffDescription { get; private set; }
/// <summary> Holds description about the tarif. </summary>
[DataMember]
public RentalDescription TariffDescription { get; private set; }
/// <summary>
/// Holds the rent state of the bike.
/// </summary>
[DataMember]
public StateInfoMutable State
{
get { return _StateInfo; }
}
/// <summary>
/// Holds the rent state of the bike.
/// </summary>
[DataMember]
public StateInfoMutable State
{
get { return _StateInfo; }
}
/// <summary>
/// Uri of the operator or null, in case of single operator setup.
/// </summary>
public Uri OperatorUri { get; }
/// <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 => _StateInfo;
/// <summary> Unused member. </summary>
IStateInfoMutable IBikeInfoMutable.State => _StateInfo;
public string Id => _Bike.Id;
public string Id => _Bike.Id;
public bool IsDemo { get; }
public bool IsDemo { get; }
/// <summary> Returns the group (TINK, Konrad, ...). </summary>
public IEnumerable<string> Group { get; }
/// <summary> Returns the group (TINK, Konrad, ...). </summary>
public IEnumerable<string> Group { get; }
public WheelType? WheelType => _Bike.WheelType;
public WheelType? WheelType => _Bike.WheelType;
public TypeOfBike? TypeOfBike => _Bike.TypeOfBike;
public TypeOfBike? TypeOfBike => _Bike.TypeOfBike;
public LockModel LockModel => _Bike.LockModel;
public LockModel LockModel => _Bike.LockModel;
public string Description => _Bike.Description;
public string Description => _Bike.Description;
public Drive Drive => _Drive;
public Drive Drive => _Drive;
/// <summary>
/// Fired whenever property of bike changes.
/// </summary>
public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
/// Fired whenever property of bike changes.
/// </summary>
public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
/// Converts the instance to text.
/// </summary>
public new string ToString()
{
return $"Id={Id}{(WheelType != null ? $", wheel(s)={WheelType}" : string.Empty)}{(TypeOfBike != null ? $", type={TypeOfBike}" : "")}, demo={IsDemo}, state={State.ToString()}, location={(!string.IsNullOrEmpty(StationId) ? $"Station {StationId}" : "On the road")}.";
}
}
/// <summary>
/// Converts the instance to text.
/// </summary>
public new string ToString()
{
return $"Id={Id}{(WheelType != null ? $", wheel(s)={WheelType}" : string.Empty)}{(TypeOfBike != null ? $", type={TypeOfBike}" : "")}, demo={IsDemo}, state={State.ToString()}, location={(!string.IsNullOrEmpty(StationId) ? $"Station {StationId}" : "On the road")}.";
}
}
}

View file

@ -5,43 +5,43 @@ using TINK.Model.State;
namespace TINK.Model.Bikes.BikeInfoNS.BC
{
/// <summary>
/// Allows to access bike info.
/// </summary>
public interface IBikeInfo
{
/// <summary>
/// Holds the bike object.
/// </summary>
BikeNS.Bike Bike { get; }
/// <summary>
/// Allows to access bike info.
/// </summary>
public interface IBikeInfo
{
/// <summary>
/// Holds the bike object.
/// </summary>
BikeNS.Bike Bike { get; }
/// <summary>
/// Holds the drive.
/// </summary>
Drive Drive { get; }
/// <summary>
/// Holds the drive.
/// </summary>
Drive Drive { get; }
/// <summary> True if bike is a demo bike. </summary>
bool IsDemo { 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> Returns the group (TINK, Konrad, ...). </summary>
IEnumerable<string> Group { get; }
/// <summary>
/// Station a which bike is located, null otherwise.
/// </summary>
string StationId { get; }
/// <summary>
/// Station a which bike is located, null otherwise.
/// </summary>
string StationId { get; }
/// <summary>
/// Uri of the operator or null, in case of single operator setup.
/// </summary>
Uri OperatorUri { 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>
RentalDescription TariffDescription { get; }
/// <summary> Holds description about the tarif. </summary>
RentalDescription TariffDescription { get; }
/// <summary>
/// Holds the rent state of the bike.
/// </summary>
IStateInfo State { get; }
}
/// <summary>
/// Holds the rent state of the bike.
/// </summary>
IStateInfo State { get; }
}
}

View file

@ -7,64 +7,64 @@ using TINK.Model.State;
namespace TINK.Model.Bikes.BikeInfoNS.BC
{
public interface IBikeInfoMutable
{
/// <summary>
/// Holds the unique id of the bike;
/// </summary>
string Id { get; }
public interface IBikeInfoMutable
{
/// <summary>
/// Holds the unique id of the bike;
/// </summary>
string Id { get; }
/// <summary> True if bike is a demo bike. </summary>
bool IsDemo { 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> Returns the group (TINK, Konrad, ...). </summary>
IEnumerable<string> Group { get; }
/// <summary>
/// Holds the count of wheels.
/// </summary>
WheelType? WheelType { get; }
/// <summary>
/// Holds the count of wheels.
/// </summary>
WheelType? WheelType { get; }
/// <summary>
/// Holds the type of bike.
/// </summary>
TypeOfBike? TypeOfBike { get; }
/// <summary>
/// Holds the type of bike.
/// </summary>
TypeOfBike? TypeOfBike { get; }
/// <summary> Gets the model of the lock. </summary>
LockModel LockModel { get; }
/// <summary> Gets the model of the lock. </summary>
LockModel LockModel { get; }
/// <summary> Holds the description of the bike. </summary>
string Description { get; }
/// <summary> Holds the description of the bike. </summary>
string Description { get; }
/// <summary>
/// Station a which bike is located, null otherwise.
/// </summary>
string StationId { get; }
/// <summary>
/// Station a which bike is located, null otherwise.
/// </summary>
string StationId { get; }
/// <summary>
/// Holds the rent state of the bike.
/// </summary>
IStateInfoMutable State { 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; }
/// <summary>
/// Uri of the operator or null, in case of single operator setup.
/// </summary>
Uri OperatorUri { get; }
/// <summary>
/// Hold the drive object.
/// </summary>
Drive Drive { get; }
/// <summary>
/// Hold the drive object.
/// </summary>
Drive Drive { get; }
event PropertyChangedEventHandler PropertyChanged;
}
event PropertyChangedEventHandler PropertyChanged;
}
public enum NotifyPropertyChangedLevel
{
/// <summary> Notify about all property changes.</summary>
All,
public enum NotifyPropertyChangedLevel
{
/// <summary> Notify about all property changes.</summary>
All,
/// <summary> Notify about no property changes.</summary>
None
}
/// <summary> Notify about no property changes.</summary>
None
}
}

View file

@ -3,143 +3,143 @@ using System.Collections.Generic;
namespace TINK.Model.Bikes.BikeInfoNS.BikeNS
{
/// <summary> Count of wheels. </summary>
/// <remarks> Numeric values of enum must match count of wheels</remarks>
public enum WheelType
{
Mono = 1,
Two = 2,
Trike = 3,
Quad = 4
}
/// <summary> Count of wheels. </summary>
/// <remarks> Numeric values of enum must match count of wheels</remarks>
public enum WheelType
{
Mono = 1,
Two = 2,
Trike = 3,
Quad = 4
}
/// <summary> Type of bike. </summary>
public enum TypeOfBike
{
Allround = 0,
Cargo = 1,
City = 2,
}
/// <summary> Type of bike. </summary>
public enum TypeOfBike
{
Allround = 0,
Cargo = 1,
City = 2,
}
/// <summary> Holds the model of lock. </summary>
public enum LockModel
{
ILockIt, // haveltec GbmH Brandenburg, Germany bluetooth lock
BordComputer, // Teilrad BC
Sigo, // Sigo Gmbh Darmstadt, Germany bike lock
}
/// <summary> Holds the model of lock. </summary>
public enum LockModel
{
ILockIt, // haveltec GbmH Brandenburg, Germany bluetooth lock
BordComputer, // Teilrad BC
Sigo, // Sigo Gmbh Darmstadt, Germany bike lock
}
/// <summary> Holds the type of lock. </summary>
public enum LockType
{
Backend, // Backend, i.e. COPRI controls lock (open, close, ...)
Bluethooth, // Lock is controlled.
}
/// <summary> Holds the type of lock. </summary>
public enum LockType
{
Backend, // Backend, i.e. COPRI controls lock (open, close, ...)
Bluethooth, // Lock is controlled.
}
public class Bike : IEquatable<Bike>
{
/// <summary>
/// Constructs a bike.
/// </summary>
/// <param name="id">Unique id of bike.</param>
public Bike(
string id,
LockModel lockModel,
WheelType? wheelType = null,
TypeOfBike? typeOfBike = null,
string description = null)
{
WheelType = wheelType;
TypeOfBike = typeOfBike;
LockModel = lockModel;
Id = id;
Description = description;
}
public class Bike : IEquatable<Bike>
{
/// <summary>
/// Constructs a bike.
/// </summary>
/// <param name="id">Unique id of bike.</param>
public Bike(
string id,
LockModel lockModel,
WheelType? wheelType = null,
TypeOfBike? typeOfBike = null,
string description = null)
{
WheelType = wheelType;
TypeOfBike = typeOfBike;
LockModel = lockModel;
Id = id;
Description = description;
}
/// <summary>
/// Holds the unique id of the bike;
/// </summary>
public string Id { get; }
/// <summary>
/// Holds the unique id of the bike;
/// </summary>
public string Id { get; }
/// <summary>
/// Holds the count of wheels.
/// </summary>
public WheelType? WheelType { get; }
/// <summary>
/// Holds the count of wheels.
/// </summary>
public WheelType? WheelType { get; }
/// <summary>
/// Holds the type of bike.
/// </summary>
public TypeOfBike? TypeOfBike { get; }
/// <summary>
/// Holds the type of bike.
/// </summary>
public TypeOfBike? TypeOfBike { get; }
/// <summary> Gets the model of the lock. </summary>
public LockModel LockModel { get; private set; }
/// <summary> Gets the model of the lock. </summary>
public LockModel LockModel { get; private set; }
/// <summary> Holds the description of the bike. </summary>
public string Description { get; }
/// <summary> Holds the description of the bike. </summary>
public string Description { get; }
/// <summary> Compares two bike object.</summary>
/// <param name="obj">Object to compare with.</param>
/// <returns>True if bikes are equal.</returns>
public override bool Equals(object obj)
{
var l_oBike = obj as Bike;
if (l_oBike == null)
{
return false;
}
/// <summary> Compares two bike object.</summary>
/// <param name="obj">Object to compare with.</param>
/// <returns>True if bikes are equal.</returns>
public override bool Equals(object obj)
{
var l_oBike = obj as Bike;
if (l_oBike == null)
{
return false;
}
return Equals(l_oBike);
}
return Equals(l_oBike);
}
/// <summary> Converts the instance to text.</summary>
public new string ToString()
{
return WheelType == null || TypeOfBike == null
? $"Id={Id}{(!string.IsNullOrEmpty(Description) ? $", {Description}" : "")}"
: $"Id={Id}{(WheelType != null ? $", wheel(s)={WheelType}" : string.Empty)}{(TypeOfBike != null ? $"type={TypeOfBike}" : "")}.";
}
/// <summary> Converts the instance to text.</summary>
public new string ToString()
{
return WheelType == null || TypeOfBike == null
? $"Id={Id}{(!string.IsNullOrEmpty(Description) ? $", {Description}" : "")}"
: $"Id={Id}{(WheelType != null ? $", wheel(s)={WheelType}" : string.Empty)}{(TypeOfBike != null ? $"type={TypeOfBike}" : "")}.";
}
/// <summary> Compares two bike object.</summary>
/// <param name="obj">Object to compare with.</param>
/// <returns>True if bikes are equal.</returns>
public bool Equals(Bike other)
{
return other != null &&
Id == other.Id &&
WheelType == other.WheelType &&
TypeOfBike == other.TypeOfBike
&& Description == other.Description;
}
/// <summary> Compares two bike object.</summary>
/// <param name="obj">Object to compare with.</param>
/// <returns>True if bikes are equal.</returns>
public bool Equals(Bike other)
{
return other != null &&
Id == other.Id &&
WheelType == other.WheelType &&
TypeOfBike == other.TypeOfBike
&& Description == other.Description;
}
/// <summary> Compares two bike object.</summary>
/// <param name="obj">Object to compare with.</param>
/// <returns>True if bikes are equal.</returns>
public static bool operator ==(Bike bike1, Bike bike2)
{
return EqualityComparer<Bike>.Default.Equals(bike1, bike2);
}
/// <summary> Compares two bike object.</summary>
/// <param name="obj">Object to compare with.</param>
/// <returns>True if bikes are equal.</returns>
public static bool operator ==(Bike bike1, Bike bike2)
{
return EqualityComparer<Bike>.Default.Equals(bike1, bike2);
}
/// <summary> Compares two bike object.</summary>
/// <param name="obj">Object to compare with.</param>
/// <returns>True if bikes are equal.</returns>
public static bool operator !=(Bike bike1, Bike bike2)
{
return !(bike1 == bike2);
}
/// <summary> Compares two bike object.</summary>
/// <param name="obj">Object to compare with.</param>
/// <returns>True if bikes are equal.</returns>
public static bool operator !=(Bike bike1, Bike bike2)
{
return !(bike1 == bike2);
}
/// <summary>
/// Generates hash code for bike object.
/// </summary>
/// <returns></returns>
public override int GetHashCode()
{
var hashCode = -390870100;
hashCode = hashCode * -1521134295 + Id.GetHashCode();
hashCode = hashCode * -1521134295 + WheelType?.GetHashCode() ?? 0;
hashCode = hashCode * -1521134295 + TypeOfBike?.GetHashCode() ?? 0;
hashCode = hashCode * -1521134295 + Description?.GetHashCode() ?? 0;
return hashCode;
}
}
/// <summary>
/// Generates hash code for bike object.
/// </summary>
/// <returns></returns>
public override int GetHashCode()
{
var hashCode = -390870100;
hashCode = hashCode * -1521134295 + Id.GetHashCode();
hashCode = hashCode * -1521134295 + WheelType?.GetHashCode() ?? 0;
hashCode = hashCode * -1521134295 + TypeOfBike?.GetHashCode() ?? 0;
hashCode = hashCode * -1521134295 + Description?.GetHashCode() ?? 0;
return hashCode;
}
}
}

View file

@ -2,21 +2,21 @@
namespace TINK.Model.Bikes.BikeInfoNS.BikeNS
{
public static class BikeExtension
{
public static LockType GetLockType(this LockModel model)
{
switch (model)
{
case LockModel.ILockIt:
return LockType.Bluethooth;
public static class BikeExtension
{
public static LockType GetLockType(this LockModel model)
{
switch (model)
{
case LockModel.ILockIt:
return LockType.Bluethooth;
case LockModel.Sigo:
return LockType.Backend;
case LockModel.Sigo:
return LockType.Backend;
default:
throw new ArgumentException($"Unsupported lock model {model} detected.");
}
}
}
default:
throw new ArgumentException($"Unsupported lock model {model} detected.");
}
}
}
}

View file

@ -7,152 +7,152 @@ using TINK.Model.State;
namespace TINK.Model.Bikes.BikeInfoNS.BluetoothLock
{
public class BikeInfo : Model.Bikes.BikeInfoNS.BC.BikeInfo, IBikeInfo
{
/// <summary>
/// Constructs a bike info object for a available bike.
/// </summary>
/// <param name="lockId">Id of the lock.</param>
/// <param name="lockGuid">GUID specifying the lock.</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>
public BikeInfo(
BikeNS.Bike bike,
Drive drive,
int lockId,
Guid lockGuid,
string currentStationId,
Uri operatorUri = null,
RentalDescription tariffDescription = null,
bool? isDemo = DEFAULTVALUEISDEMO,
IEnumerable<string> group = null) : base(
new StateInfo(),
bike != null
? new BikeNS.Bike(
bike.Id,
LockModel.ILockIt /* Ensure consistend lock model value */,
bike.WheelType,
bike.TypeOfBike,
bike.Description)
: throw new ArgumentNullException(nameof(bike)),
drive,
isDemo,
group,
currentStationId,
operatorUri,
tariffDescription)
{
LockInfo = new Model.Bikes.BikeInfoNS.BluetoothLock.LockInfo.Builder { Id = lockId, Guid = lockGuid }.Build();
}
public class BikeInfo : Model.Bikes.BikeInfoNS.BC.BikeInfo, IBikeInfo
{
/// <summary>
/// Constructs a bike info object for a available bike.
/// </summary>
/// <param name="lockId">Id of the lock.</param>
/// <param name="lockGuid">GUID specifying the lock.</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>
public BikeInfo(
BikeNS.Bike bike,
Drive drive,
int lockId,
Guid lockGuid,
string currentStationId,
Uri operatorUri = null,
RentalDescription tariffDescription = null,
bool? isDemo = DEFAULTVALUEISDEMO,
IEnumerable<string> group = null) : base(
new StateInfo(),
bike != null
? new BikeNS.Bike(
bike.Id,
LockModel.ILockIt /* Ensure consistend lock model value */,
bike.WheelType,
bike.TypeOfBike,
bike.Description)
: throw new ArgumentNullException(nameof(bike)),
drive,
isDemo,
group,
currentStationId,
operatorUri,
tariffDescription)
{
LockInfo = new Model.Bikes.BikeInfoNS.BluetoothLock.LockInfo.Builder { Id = lockId, Guid = lockGuid }.Build();
}
/// <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="lockId">Id of the lock.</param>
/// <param name="lockGuid">GUID specifying the lock.</param>
/// <param name="requestedAt">Date time when bike was requested</param>
/// <param name="mailAddress">Mail address of user which requested 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="dateTimeProvider">Date time provider to calculate reaining time.</param>
public BikeInfo(
BikeNS.Bike bike,
Drive drive,
int lockId,
Guid lockGuid,
byte[] userKey,
byte[] adminKey,
byte[] seed,
DateTime requestedAt,
string mailAddress,
string currentStationId,
Uri operatorUri,
RentalDescription tariffDescription,
Func<DateTime> dateTimeProvider,
bool? isDemo = DEFAULTVALUEISDEMO,
IEnumerable<string> group = null) : base(
new StateInfo(
dateTimeProvider,
requestedAt,
mailAddress,
""),
bike != null
? new BikeNS.Bike(
bike.Id,
LockModel.ILockIt /* Ensure consistend lock model value */,
bike.WheelType,
bike.TypeOfBike,
bike.Description)
: throw new ArgumentNullException(nameof(bike)),
drive,
isDemo,
group,
currentStationId,
operatorUri,
tariffDescription)
{
LockInfo = new Model.Bikes.BikeInfoNS.BluetoothLock.LockInfo.Builder { Id = lockId, Guid = lockGuid, UserKey = userKey, AdminKey = adminKey, Seed = seed }.Build();
}
/// <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="lockId">Id of the lock.</param>
/// <param name="lockGuid">GUID specifying the lock.</param>
/// <param name="requestedAt">Date time when bike was requested</param>
/// <param name="mailAddress">Mail address of user which requested 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="dateTimeProvider">Date time provider to calculate reaining time.</param>
public BikeInfo(
BikeNS.Bike bike,
Drive drive,
int lockId,
Guid lockGuid,
byte[] userKey,
byte[] adminKey,
byte[] seed,
DateTime requestedAt,
string mailAddress,
string currentStationId,
Uri operatorUri,
RentalDescription tariffDescription,
Func<DateTime> dateTimeProvider,
bool? isDemo = DEFAULTVALUEISDEMO,
IEnumerable<string> group = null) : base(
new StateInfo(
dateTimeProvider,
requestedAt,
mailAddress,
""),
bike != null
? new BikeNS.Bike(
bike.Id,
LockModel.ILockIt /* Ensure consistend lock model value */,
bike.WheelType,
bike.TypeOfBike,
bike.Description)
: throw new ArgumentNullException(nameof(bike)),
drive,
isDemo,
group,
currentStationId,
operatorUri,
tariffDescription)
{
LockInfo = new Model.Bikes.BikeInfoNS.BluetoothLock.LockInfo.Builder { Id = lockId, Guid = lockGuid, UserKey = userKey, AdminKey = adminKey, Seed = seed }.Build();
}
/// <summary>
/// Constructs a bike info object for a booked bike.
/// </summary>
/// <param name="id">Unique id of bike.</param>
/// <param name="lockId">Id of the lock.</param>
/// <param name="lockGuid">GUID specifying the lock.</param>
/// <param name="bookedAt">Date time when bike was booked</param>
/// <param name="mailAddress">Mail address of user which booked 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="wheelType"></param>
public BikeInfo(
BikeNS.Bike bike,
Drive drive,
int lockId,
Guid lockGuid,
byte[] userKey,
byte[] adminKey,
byte[] seed,
DateTime bookedAt,
string mailAddress,
string currentStationId,
Uri operatorUri,
RentalDescription tariffDescription = null,
bool? isDemo = DEFAULTVALUEISDEMO,
IEnumerable<string> group = null) : base(
new StateInfo(
bookedAt,
mailAddress,
""),
bike != null
? new BikeNS.Bike(
bike.Id,
LockModel.ILockIt /* Ensure consistend lock model value */,
bike.WheelType,
bike.TypeOfBike,
bike.Description)
: throw new ArgumentNullException(),
drive,
isDemo,
group,
currentStationId,
operatorUri,
tariffDescription)
{
LockInfo = new Model.Bikes.BikeInfoNS.BluetoothLock.LockInfo.Builder { Id = lockId, Guid = lockGuid, UserKey = userKey, AdminKey = adminKey, Seed = seed }.Build();
}
/// <summary>
/// Constructs a bike info object for a booked bike.
/// </summary>
/// <param name="id">Unique id of bike.</param>
/// <param name="lockId">Id of the lock.</param>
/// <param name="lockGuid">GUID specifying the lock.</param>
/// <param name="bookedAt">Date time when bike was booked</param>
/// <param name="mailAddress">Mail address of user which booked 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="wheelType"></param>
public BikeInfo(
BikeNS.Bike bike,
Drive drive,
int lockId,
Guid lockGuid,
byte[] userKey,
byte[] adminKey,
byte[] seed,
DateTime bookedAt,
string mailAddress,
string currentStationId,
Uri operatorUri,
RentalDescription tariffDescription = null,
bool? isDemo = DEFAULTVALUEISDEMO,
IEnumerable<string> group = null) : base(
new StateInfo(
bookedAt,
mailAddress,
""),
bike != null
? new BikeNS.Bike(
bike.Id,
LockModel.ILockIt /* Ensure consistend lock model value */,
bike.WheelType,
bike.TypeOfBike,
bike.Description)
: throw new ArgumentNullException(),
drive,
isDemo,
group,
currentStationId,
operatorUri,
tariffDescription)
{
LockInfo = new Model.Bikes.BikeInfoNS.BluetoothLock.LockInfo.Builder { Id = lockId, Guid = lockGuid, UserKey = userKey, AdminKey = adminKey, Seed = seed }.Build();
}
public BikeInfo(Model.Bikes.BikeInfoNS.BC.BikeInfo bikeInfo, Model.Bikes.BikeInfoNS.BluetoothLock.LockInfo lockInfo) : base(
bikeInfo ?? throw new ArgumentException($"Can not copy-construct {typeof(BikeInfo).Name}-object. Source bike info must not be null."))
{
LockInfo = lockInfo
?? throw new ArgumentException($"Can not copy-construct {typeof(BikeInfo).Name}-object. Source lock object must not be null.");
}
public BikeInfo(Model.Bikes.BikeInfoNS.BC.BikeInfo bikeInfo, Model.Bikes.BikeInfoNS.BluetoothLock.LockInfo lockInfo) : base(
bikeInfo ?? throw new ArgumentException($"Can not copy-construct {typeof(BikeInfo).Name}-object. Source bike info must not be null."))
{
LockInfo = lockInfo
?? throw new ArgumentException($"Can not copy-construct {typeof(BikeInfo).Name}-object. Source lock object must not be null.");
}
public Model.Bikes.BikeInfoNS.BluetoothLock.LockInfo LockInfo { get; private set; }
}
public Model.Bikes.BikeInfoNS.BluetoothLock.LockInfo LockInfo { get; private set; }
}
}

View file

@ -2,34 +2,39 @@
namespace TINK.Model.Bikes.BikeInfoNS.BluetoothLock
{
public class BikeInfoMutable : Model.Bikes.BikeInfoNS.BC.BikeInfoMutable, IBikeInfoMutable
{
/// <summary> Constructs a bike object from source. </summary>
public BikeInfoMutable(BikeInfo bike, string stationName) : base(
bike != null
? bike.Bike
: throw new ArgumentNullException(nameof(bike)),
bike.Drive,
bike.IsDemo,
bike.Group,
bike.StationId,
stationName,
bike.OperatorUri,
bike.TariffDescription,
() => DateTime.Now,
bike.State)
{
LockInfo = new LockInfoMutable(
bike.LockInfo.Id,
bike.LockInfo.Guid,
bike.LockInfo.UserKey,
bike.LockInfo.AdminKey,
bike.LockInfo.Seed,
bike.LockInfo.State);
}
public class BikeInfoMutable : Model.Bikes.BikeInfoNS.BC.BikeInfoMutable, IBikeInfoMutable
{
/// <summary> Constructs a bike object from source. </summary>
public BikeInfoMutable(BikeInfo bike, string stationName) : base(
bike != null
? bike.Bike
: throw new ArgumentNullException(nameof(bike)),
bike.Drive,
bike.IsDemo,
bike.Group,
bike.StationId,
stationName,
bike.OperatorUri,
bike.TariffDescription,
() => DateTime.Now,
bike.State)
{
LockInfo = new LockInfoMutable(
bike.LockInfo.Id,
bike.LockInfo.Guid,
bike.LockInfo.UserKey,
bike.LockInfo.AdminKey,
bike.LockInfo.Seed,
bike.LockInfo.State);
}
public LockInfoMutable LockInfo { get; }
public LockInfoMutable LockInfo { get; }
ILockInfoMutable IBikeInfoMutable.LockInfo => LockInfo;
}
ILockInfoMutable IBikeInfoMutable.LockInfo => LockInfo;
public new string ToString()
{
return $"Id={Id}{(TypeOfBike != null ? $";type={TypeOfBike}" : "")};state={State}";
}
}
}

View file

@ -1,6 +1,6 @@
namespace TINK.Model.Bikes.BikeInfoNS.BluetoothLock
{
public interface IBikeInfo : BC.IBikeInfo
{
}
public interface IBikeInfo : BC.IBikeInfo
{
}
}

View file

@ -1,7 +1,7 @@
namespace TINK.Model.Bikes.BikeInfoNS.BluetoothLock
{
public interface IBikeInfoMutable : BikeInfoNS.BC.IBikeInfoMutable
{
ILockInfoMutable LockInfo { get; }
}
public interface IBikeInfoMutable : BikeInfoNS.BC.IBikeInfoMutable
{
ILockInfoMutable LockInfo { get; }
}
}

View file

@ -2,22 +2,22 @@
namespace TINK.Model.Bikes.BikeInfoNS.BluetoothLock
{
public interface ILockInfoMutable
{
/// <summary> Identification number of bluetooth lock.</summary>
int Id { get; }
public interface ILockInfoMutable
{
/// <summary> Identification number of bluetooth lock.</summary>
int Id { get; }
/// <summary> Gets the user key.</summary>
byte[] UserKey { get; }
/// <summary> Gets the user key.</summary>
byte[] UserKey { get; }
LockingState State { get; set; }
LockingState State { get; set; }
/// <summary> Holds the percentage of lock battery.</summary>
double BatteryPercentage { get; set; }
/// <summary> Holds the percentage of lock battery.</summary>
double BatteryPercentage { get; set; }
/// <summary> Changes during runtime: Can be unknown when set from copri and chang to a valid value when set from lock.</summary>
Guid Guid { get; set; }
/// <summary> Changes during runtime: Can be unknown when set from copri and chang to a valid value when set from lock.</summary>
Guid Guid { get; set; }
byte[] Seed { get; }
}
byte[] Seed { get; }
}
}

View file

@ -2,52 +2,52 @@
namespace TINK.Model.Bikes.BikeInfoNS.BluetoothLock
{
public class LockInfoMutable : TINK.Model.Bikes.BikeInfoNS.BluetoothLock.ILockInfoMutable
{
/// <summary> Lock info object. </summary>
private Model.Bikes.BikeInfoNS.BluetoothLock.LockInfo LockInfo { get; set; }
public class LockInfoMutable : TINK.Model.Bikes.BikeInfoNS.BluetoothLock.ILockInfoMutable
{
/// <summary> Lock info object. </summary>
private Model.Bikes.BikeInfoNS.BluetoothLock.LockInfo LockInfo { get; set; }
/// <summary> Constructs a bluetooth lock info object. </summary>
/// <param name="id">Id of lock must always been known when constructing an lock info object.</param>
public LockInfoMutable(
int id,
Guid guid,
byte[] userKey,
byte[] adminKey,
byte[] seed,
Model.Bikes.BikeInfoNS.BluetoothLock.LockingState state)
{
LockInfo = new Model.Bikes.BikeInfoNS.BluetoothLock.LockInfo.Builder() { Id = id, Guid = guid, UserKey = userKey, AdminKey = adminKey, Seed = seed, State = state }.Build();
}
/// <summary> Constructs a bluetooth lock info object. </summary>
/// <param name="id">Id of lock must always been known when constructing an lock info object.</param>
public LockInfoMutable(
int id,
Guid guid,
byte[] userKey,
byte[] adminKey,
byte[] seed,
Model.Bikes.BikeInfoNS.BluetoothLock.LockingState state)
{
LockInfo = new Model.Bikes.BikeInfoNS.BluetoothLock.LockInfo.Builder() { Id = id, Guid = guid, UserKey = userKey, AdminKey = adminKey, Seed = seed, State = state }.Build();
}
public int Id => LockInfo.Id;
public int Id => LockInfo.Id;
/// <summary> Changes during runtime: Can be unknown when set from copri and chang to a valid value when set from lock.</summary>
public Guid Guid
{
get => LockInfo.Guid;
set => LockInfo = new Model.Bikes.BikeInfoNS.BluetoothLock.LockInfo.Builder(LockInfo) { Guid = value }.Build();
}
/// <summary> Changes during runtime: Can be unknown when set from copri and chang to a valid value when set from lock.</summary>
public Guid Guid
{
get => LockInfo.Guid;
set => LockInfo = new Model.Bikes.BikeInfoNS.BluetoothLock.LockInfo.Builder(LockInfo) { Guid = value }.Build();
}
public byte[] Seed => LockInfo.Seed;
public byte[] Seed => LockInfo.Seed;
public byte[] UserKey => LockInfo.UserKey;
public byte[] UserKey => LockInfo.UserKey;
public byte[] AdminKey => LockInfo.AdminKey;
public byte[] AdminKey => LockInfo.AdminKey;
public Model.Bikes.BikeInfoNS.BluetoothLock.LockingState State
{
get => LockInfo.State;
set => LockInfo = new Model.Bikes.BikeInfoNS.BluetoothLock.LockInfo.Builder(LockInfo) { State = value }.Build();
}
public Model.Bikes.BikeInfoNS.BluetoothLock.LockingState State
{
get => LockInfo.State;
set => LockInfo = new Model.Bikes.BikeInfoNS.BluetoothLock.LockInfo.Builder(LockInfo) { State = value }.Build();
}
/// <summary> Holds the percentage of lock battery.</summary>
public double BatteryPercentage { get; set; } = double.NaN;
/// <summary> Holds the percentage of lock battery.</summary>
public double BatteryPercentage { get; set; } = double.NaN;
/// <summary> Loads lock info object from values. </summary>
public void Load(int id, Guid guid, byte[] seed, byte[] userKey, byte[] adminKey)
{
LockInfo = new Model.Bikes.BikeInfoNS.BluetoothLock.LockInfo.Builder(LockInfo) { Id = id, Guid = guid, Seed = seed, UserKey = userKey, AdminKey = adminKey }.Build();
}
}
/// <summary> Loads lock info object from values. </summary>
public void Load(int id, Guid guid, byte[] seed, byte[] userKey, byte[] adminKey)
{
LockInfo = new Model.Bikes.BikeInfoNS.BluetoothLock.LockInfo.Builder(LockInfo) { Id = id, Guid = guid, Seed = seed, UserKey = userKey, AdminKey = adminKey }.Build();
}
}
}

View file

@ -7,155 +7,155 @@ using TINK.Model.State;
namespace TINK.Model.Bikes.BikeInfoNS.CopriLock
{
public class BikeInfo : BC.BikeInfo
{
/// <summary>
/// Constructs a bike info object for a available bike or bike for which feed back is pending.
/// </summary>
/// <param name="bike">Bike object.</param>
/// <param name="currentStationId">Id of station where bike is located.</param>
/// <param name="lockInfo">Lock info.</param>
/// <param name="isFeedbackPending">If true user has not yet given feedback after returning bike.</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>
public BikeInfo(
BikeNS.Bike bike,
Drive drive,
string currentStationId,
LockInfo lockInfo,
bool isFeedbackPending = false,
Uri operatorUri = null,
RentalDescription tariffDescription = null,
bool? isDemo = DEFAULTVALUEISDEMO,
IEnumerable<string> group = null,
IMiniSurveyModel miniSurvey = null,
string co2Saving = null) : base(
new StateInfo(isFeedbackPending),
bike != null
? new Bike(
bike.Id,
LockModel.Sigo,
bike.WheelType /* Ensure consistend lock model value */,
bike.TypeOfBike,
bike.Description)
: throw new ArgumentNullException(nameof(bike)),
drive,
isDemo,
group,
currentStationId,
operatorUri,
tariffDescription)
{
LockInfo = lockInfo;
MiniSurvey = miniSurvey;
Co2Saving = co2Saving;
}
public class BikeInfo : BC.BikeInfo
{
/// <summary>
/// Constructs a bike info object for a available bike or bike for which feed back is pending.
/// </summary>
/// <param name="bike">Bike object.</param>
/// <param name="currentStationId">Id of station where bike is located.</param>
/// <param name="lockInfo">Lock info.</param>
/// <param name="isFeedbackPending">If true user has not yet given feedback after returning bike.</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>
public BikeInfo(
BikeNS.Bike bike,
Drive drive,
string currentStationId,
LockInfo lockInfo,
bool isFeedbackPending = false,
Uri operatorUri = null,
RentalDescription tariffDescription = null,
bool? isDemo = DEFAULTVALUEISDEMO,
IEnumerable<string> group = null,
IMiniSurveyModel miniSurvey = null,
string co2Saving = null) : base(
new StateInfo(isFeedbackPending),
bike != null
? new Bike(
bike.Id,
LockModel.Sigo,
bike.WheelType /* Ensure consistend lock model value */,
bike.TypeOfBike,
bike.Description)
: throw new ArgumentNullException(nameof(bike)),
drive,
isDemo,
group,
currentStationId,
operatorUri,
tariffDescription)
{
LockInfo = lockInfo;
MiniSurvey = miniSurvey;
Co2Saving = co2Saving;
}
/// <summary>
/// Constructs a bike info object for a requested bike.
/// </summary>
/// <param name="bike">Bike object.</param>
/// <param name="requestedAt">Date time when bike was requested</param>
/// <param name="mailAddress">Mail address of user which requested bike.</param>
/// <param name="currentStationId">Name of station where bike is located, null if bike is on the road.</param>
/// <param name="lockInfo">Lock info.</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="dateTimeProvider">Provider for current date time to calculate remainig time on demand for state of type reserved.</param>
public BikeInfo(
BikeNS.Bike bike,
Drive drive,
DateTime requestedAt,
string mailAddress,
string currentStationId,
LockInfo lockInfo,
Uri operatorUri,
RentalDescription tariffDescription,
Func<DateTime> dateTimeProvider,
bool? isDemo = DEFAULTVALUEISDEMO,
IEnumerable<string> group = null) : base(
new StateInfo(
dateTimeProvider,
requestedAt,
mailAddress,
""),
bike != null
? new BikeNS.Bike(
bike.Id,
LockModel.Sigo /* Ensure consistend lock model value */,
bike.WheelType,
bike.TypeOfBike,
bike.Description)
: throw new ArgumentNullException(nameof(bike)),
drive,
isDemo,
group,
currentStationId,
operatorUri,
tariffDescription)
{
LockInfo = lockInfo;
MiniSurvey = new MiniSurveyModel();
Co2Saving = string.Empty;
}
/// <summary>
/// Constructs a bike info object for a requested bike.
/// </summary>
/// <param name="bike">Bike object.</param>
/// <param name="requestedAt">Date time when bike was requested</param>
/// <param name="mailAddress">Mail address of user which requested bike.</param>
/// <param name="currentStationId">Name of station where bike is located, null if bike is on the road.</param>
/// <param name="lockInfo">Lock info.</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="dateTimeProvider">Provider for current date time to calculate remainig time on demand for state of type reserved.</param>
public BikeInfo(
BikeNS.Bike bike,
Drive drive,
DateTime requestedAt,
string mailAddress,
string currentStationId,
LockInfo lockInfo,
Uri operatorUri,
RentalDescription tariffDescription,
Func<DateTime> dateTimeProvider,
bool? isDemo = DEFAULTVALUEISDEMO,
IEnumerable<string> group = null) : base(
new StateInfo(
dateTimeProvider,
requestedAt,
mailAddress,
""),
bike != null
? new BikeNS.Bike(
bike.Id,
LockModel.Sigo /* Ensure consistend lock model value */,
bike.WheelType,
bike.TypeOfBike,
bike.Description)
: throw new ArgumentNullException(nameof(bike)),
drive,
isDemo,
group,
currentStationId,
operatorUri,
tariffDescription)
{
LockInfo = lockInfo;
MiniSurvey = new MiniSurveyModel();
Co2Saving = string.Empty;
}
/// <summary>
/// Constructs a bike info object for a booked bike.
/// </summary>
/// <param name="bike">Bike object.</param>
/// <param name="bookedAt">Date time when bike was booked</param>
/// <param name="mailAddress">Mail address of user which booked bike.</param>
/// <param name="currentStationId">Name of station where bike is located, null if bike is on the road.</param>
/// <param name="lockInfo">Lock info.</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>
public BikeInfo(
BikeNS.Bike bike,
Drive drive,
DateTime bookedAt,
string mailAddress,
string currentStationId,
LockInfo lockInfo,
Uri operatorUri,
RentalDescription tariffDescription = null,
bool? isDemo = DEFAULTVALUEISDEMO,
IEnumerable<string> group = null) : base(
new StateInfo(
bookedAt,
mailAddress,
""),
bike != null
? new BikeNS.Bike(
bike.Id,
LockModel.Sigo /* Ensure consistend lock model value */,
bike.WheelType,
bike.TypeOfBike,
bike.Description)
: throw new ArgumentNullException(nameof(bike)),
drive,
isDemo,
group,
currentStationId,
operatorUri,
tariffDescription)
{
LockInfo = lockInfo;
MiniSurvey = new MiniSurveyModel();
Co2Saving = string.Empty;
}
/// <summary>
/// Constructs a bike info object for a booked bike.
/// </summary>
/// <param name="bike">Bike object.</param>
/// <param name="bookedAt">Date time when bike was booked</param>
/// <param name="mailAddress">Mail address of user which booked bike.</param>
/// <param name="currentStationId">Name of station where bike is located, null if bike is on the road.</param>
/// <param name="lockInfo">Lock info.</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>
public BikeInfo(
BikeNS.Bike bike,
Drive drive,
DateTime bookedAt,
string mailAddress,
string currentStationId,
LockInfo lockInfo,
Uri operatorUri,
RentalDescription tariffDescription = null,
bool? isDemo = DEFAULTVALUEISDEMO,
IEnumerable<string> group = null) : base(
new StateInfo(
bookedAt,
mailAddress,
""),
bike != null
? new BikeNS.Bike(
bike.Id,
LockModel.Sigo /* Ensure consistend lock model value */,
bike.WheelType,
bike.TypeOfBike,
bike.Description)
: throw new ArgumentNullException(nameof(bike)),
drive,
isDemo,
group,
currentStationId,
operatorUri,
tariffDescription)
{
LockInfo = lockInfo;
MiniSurvey = new MiniSurveyModel();
Co2Saving = string.Empty;
}
public BikeInfo(BC.BikeInfo bikeInfo, LockInfo lockInfo) : base(
bikeInfo ?? throw new ArgumentException($"Can not copy-construct {typeof(BikeInfo).Name}-object. Source bike info must not be null."))
{
LockInfo = lockInfo
?? throw new ArgumentException($"Can not copy-construct {typeof(BikeInfo).Name}-object. Source lock object must not be null.");
}
public BikeInfo(BC.BikeInfo bikeInfo, LockInfo lockInfo) : base(
bikeInfo ?? throw new ArgumentException($"Can not copy-construct {typeof(BikeInfo).Name}-object. Source bike info must not be null."))
{
LockInfo = lockInfo
?? throw new ArgumentException($"Can not copy-construct {typeof(BikeInfo).Name}-object. Source lock object must not be null.");
}
/// <summary> Holds the lock info.</summary>
public LockInfo LockInfo { get; private set; }
/// <summary> Holds the lock info.</summary>
public LockInfo LockInfo { get; private set; }
public IMiniSurveyModel MiniSurvey { get; private set; }
public IMiniSurveyModel MiniSurvey { get; private set; }
public string Co2Saving { get; private set; }
}
public string Co2Saving { get; private set; }
}
}

View file

@ -2,46 +2,46 @@
namespace TINK.Model.Bikes.BikeInfoNS.CopriLock
{
public class BikeInfoMutable : BC.BikeInfoMutable, IBikeInfoMutable
{
/// <summary> Constructs a bike object from source. </summary>
public BikeInfoMutable(BikeInfo bike, string stationName) : base(
bike != null
? bike.Bike
: throw new ArgumentNullException(nameof(bike)),
bike.Drive,
bike.IsDemo,
bike.Group,
bike.StationId,
stationName,
bike.OperatorUri,
bike.TariffDescription,
() => DateTime.Now,
bike.State)
{
LockInfo = new LockInfoMutable(bike.LockInfo.State);
public class BikeInfoMutable : BC.BikeInfoMutable, IBikeInfoMutable
{
/// <summary> Constructs a bike object from source. </summary>
public BikeInfoMutable(BikeInfo bike, string stationName) : base(
bike != null
? bike.Bike
: throw new ArgumentNullException(nameof(bike)),
bike.Drive,
bike.IsDemo,
bike.Group,
bike.StationId,
stationName,
bike.OperatorUri,
bike.TariffDescription,
() => DateTime.Now,
bike.State)
{
LockInfo = new LockInfoMutable(bike.LockInfo.State);
BookingFinishedModel = new BookingFinishedModel
{
Co2Saving = bike.Co2Saving,
MiniSurvey = new MiniSurvey.MiniSurveyModel()
};
BookingFinishedModel = new BookingFinishedModel
{
Co2Saving = bike.Co2Saving,
MiniSurvey = new MiniSurvey.MiniSurveyModel()
};
if ((bike?.MiniSurvey?.Questions) == null
|| bike.MiniSurvey.Questions.Count <= 0)
{
// No querries to add.
return;
}
if ((bike?.MiniSurvey?.Questions) == null
|| bike.MiniSurvey.Questions.Count <= 0)
{
// No querries to add.
return;
}
// Add a dummy querry. Querries are not yet read from COPRI but compiled into the app.
BookingFinishedModel.MiniSurvey.Questions.Add("q1", new MiniSurvey.QuestionModel());
}
// Add a dummy querry. Querries are not yet read from COPRI but compiled into the app.
BookingFinishedModel.MiniSurvey.Questions.Add("q1", new MiniSurvey.QuestionModel());
}
public LockInfoMutable LockInfo { get; }
public LockInfoMutable LockInfo { get; }
ILockInfoMutable IBikeInfoMutable.LockInfo => LockInfo;
ILockInfoMutable IBikeInfoMutable.LockInfo => LockInfo;
public IBookingFinishedModel BookingFinishedModel { get; }
}
public IBookingFinishedModel BookingFinishedModel { get; }
}
}

View file

@ -1,9 +1,9 @@
namespace TINK.Model.Bikes.BikeInfoNS.CopriLock
{
public interface IBikeInfoMutable : BikeInfoNS.BC.IBikeInfoMutable
{
ILockInfoMutable LockInfo { get; }
public interface IBikeInfoMutable : BikeInfoNS.BC.IBikeInfoMutable
{
ILockInfoMutable LockInfo { get; }
IBookingFinishedModel BookingFinishedModel { get; }
}
IBookingFinishedModel BookingFinishedModel { get; }
}
}

View file

@ -1,7 +1,7 @@
namespace TINK.Model.Bikes.BikeInfoNS.CopriLock
{
public interface ILockInfoMutable
{
LockingState State { get; set; }
}
public interface ILockInfoMutable
{
LockingState State { get; set; }
}
}

View file

@ -1,30 +1,30 @@
namespace TINK.Model.Bikes.BikeInfoNS.CopriLock
{
public class LockInfoMutable : ILockInfoMutable
{
/// <summary> Lock info object. </summary>
private LockInfo LockInfo { get; set; }
public class LockInfoMutable : ILockInfoMutable
{
/// <summary> Lock info object. </summary>
private LockInfo LockInfo { get; set; }
/// <summary> Constructs a bluetooth lock info object. </summary>
/// <param name="id">Id of lock must always been known when constructing an lock info object.</param>
public LockInfoMutable(LockingState state)
{
LockInfo = new LockInfo.Builder() { State = state }.Build();
}
/// <summary> Constructs a bluetooth lock info object. </summary>
/// <param name="id">Id of lock must always been known when constructing an lock info object.</param>
public LockInfoMutable(LockingState state)
{
LockInfo = new LockInfo.Builder() { State = state }.Build();
}
public LockingState State
{
get => LockInfo.State;
set => LockInfo = new LockInfo.Builder(LockInfo) { State = value }.Build();
}
public LockingState State
{
get => LockInfo.State;
set => LockInfo = new LockInfo.Builder(LockInfo) { State = value }.Build();
}
/// <summary> Holds the percentage of lock battery.</summary>
public double BatteryPercentage { get; set; } = double.NaN;
/// <summary> Holds the percentage of lock battery.</summary>
public double BatteryPercentage { get; set; } = double.NaN;
/// <summary> Loads lock info object from values. </summary>
public void Load()
{
LockInfo = new LockInfo.Builder(LockInfo) { }.Build();
}
}
/// <summary> Loads lock info object from values. </summary>
public void Load()
{
LockInfo = new LockInfo.Builder(LockInfo) { }.Build();
}
}
}

View file

@ -2,109 +2,109 @@
namespace TINK.Model.Bikes.BikeInfoNS.DriveNS.BatteryNS
{
public class Battery : IBattery
{
private Battery() { }
public class Battery : IBattery
{
private Battery() { }
/// <summary>
/// Holds the current charging level of the battery in percent, double.NaN if unknown.
/// </summary>
public double CurrentChargePercent { get; private set; } = double.NaN;
/// <summary>
/// Holds the current charging level of the battery in percent, double.NaN if unknown.
/// </summary>
public double CurrentChargePercent { get; private set; } = double.NaN;
/// <summary>
/// Holds the current chargeing level of the battery in bars, null if unkonwn.
/// </summary>
public int? CurrentChargeBars { get; private set; } = null;
/// <summary>
/// Holds the current chargeing level of the battery in bars, null if unkonwn.
/// </summary>
public int? CurrentChargeBars { get; private set; } = null;
/// <summary>
/// Holds the maximum chargeing level of the battery in bars, null if unkonwn.
/// </summary>
public int? MaxChargeBars { get; private set; } = null;
/// <summary>
/// Holds the maximum chargeing level of the battery in bars, null if unkonwn.
/// </summary>
public int? MaxChargeBars { get; private set; } = null;
/// <summary>
/// Holds whether backend is aware of battery charging level.
/// </summary>
public bool? IsBackendAccessible { get; private set; } = null;
/// <summary>
/// Holds whether backend is aware of battery charging level.
/// </summary>
public bool? IsBackendAccessible { get; private set; } = null;
/// <summary>
/// Holds whether to display battery level or not.
/// </summary>
public bool? IsHidden { get; private set; } = null;
/// <summary>
/// Holds whether to display battery level or not.
/// </summary>
public bool? IsHidden { get; private set; } = null;
public class Builder
{
/// <summary>
/// Holds the current chargeing level of the battery in bars.
/// </summary>
public int? CurrentChargeBars { get; set; } = null;
public class Builder
{
/// <summary>
/// Holds the current chargeing level of the battery in bars.
/// </summary>
public int? CurrentChargeBars { get; set; } = null;
/// <summary>
/// Holds the maximum chargeing level of the battery in bars.
/// </summary>
public int? MaxChargeBars { get; set; } = null;
/// <summary>
/// Holds the maximum chargeing level of the battery in bars.
/// </summary>
public int? MaxChargeBars { get; set; } = null;
/// <summary>
/// Holds the current charging level of the battery in percent.
/// </summary>
public double CurrentChargePercent { get; set; } = double.NaN;
/// <summary>
/// Holds the current charging level of the battery in percent.
/// </summary>
public double CurrentChargePercent { get; set; } = double.NaN;
/// <summary>
/// Holds whether backend is aware of battery charging level.
/// </summary>
public bool? IsBackendAccessible { get; set; } = null;
/// <summary>
/// Holds whether backend is aware of battery charging level.
/// </summary>
public bool? IsBackendAccessible { get; set; } = null;
/// <summary>
/// Holds whether to display battery level or not.
/// </summary>
public bool? IsHidden { get; set; } = null;
/// <summary>
/// Holds whether to display battery level or not.
/// </summary>
public bool? IsHidden { get; set; } = null;
public Battery Build()
{
if (!double.IsNaN(CurrentChargePercent)
&& (CurrentChargePercent < 0 || 100 < CurrentChargePercent))
{
// Invalid filling level detected
CurrentChargePercent = double.NaN;
}
public Battery Build()
{
if (!double.IsNaN(CurrentChargePercent)
&& (CurrentChargePercent < 0 || 100 < CurrentChargePercent))
{
// Invalid filling level detected
CurrentChargePercent = double.NaN;
}
if (CurrentChargeBars < 0)
{
// Current value of bars must never be smaller zero.
CurrentChargeBars = null;
}
if (CurrentChargeBars < 0)
{
// Current value of bars must never be smaller zero.
CurrentChargeBars = null;
}
if (MaxChargeBars < 0)
{
// Max value of bars must never be smaller zero.
MaxChargeBars = null;
}
if (MaxChargeBars < 0)
{
// Max value of bars must never be smaller zero.
MaxChargeBars = null;
}
if (CurrentChargeBars != null
&& MaxChargeBars == null)
{
// If current charge bars is set, max charge must be set as well.
Log.ForContext<Battery>().Error($"Current bars value can not be set to {CurrentChargeBars} if max bars is not se.");
CurrentChargeBars = null;
}
if (CurrentChargeBars != null
&& MaxChargeBars == null)
{
// If current charge bars is set, max charge must be set as well.
Log.ForContext<Battery>().Error($"Current bars value can not be set to {CurrentChargeBars} if max bars is not se.");
CurrentChargeBars = null;
}
if (CurrentChargeBars != null
&& MaxChargeBars != null
&& CurrentChargeBars > MaxChargeBars)
{
// If current charge bars must never be larger than max charge bars.
Log.ForContext<Battery>().Error($"Invalid current bars value {CurrentChargeBars} detected. Value must never be largen than max value bars {MaxChargeBars}.");
CurrentChargeBars = null;
}
if (CurrentChargeBars != null
&& MaxChargeBars != null
&& CurrentChargeBars > MaxChargeBars)
{
// If current charge bars must never be larger than max charge bars.
Log.ForContext<Battery>().Error($"Invalid current bars value {CurrentChargeBars} detected. Value must never be largen than max value bars {MaxChargeBars}.");
CurrentChargeBars = null;
}
return new Battery
{
CurrentChargeBars = CurrentChargeBars,
MaxChargeBars = MaxChargeBars,
CurrentChargePercent = CurrentChargePercent,
IsBackendAccessible = IsBackendAccessible,
IsHidden = IsHidden
};
}
}
}
return new Battery
{
CurrentChargeBars = CurrentChargeBars,
MaxChargeBars = MaxChargeBars,
CurrentChargePercent = CurrentChargePercent,
IsBackendAccessible = IsBackendAccessible,
IsHidden = IsHidden
};
}
}
}
}

View file

@ -1,31 +1,31 @@

namespace TINK.Model.Bikes.BikeInfoNS.DriveNS.BatteryNS
{
public interface IBattery
{
/// <summary>
/// Holds the current charging level of the battery in percent, double.NaN if unknown.
/// </summary>
double CurrentChargePercent { get; }
public interface IBattery
{
/// <summary>
/// Holds the current charging level of the battery in percent, double.NaN if unknown.
/// </summary>
double CurrentChargePercent { get; }
/// <summary>
/// Holds the current chargeing level of the battery in bars. Must not be arger than MaxChargeBars, null if unkonwn.
/// </summary>
int? CurrentChargeBars { get; }
/// <summary>
/// Holds the current chargeing level of the battery in bars. Must not be arger than MaxChargeBars, null if unkonwn.
/// </summary>
int? CurrentChargeBars { get; }
/// <summary>
/// Holds the maximum chargeing level of the battery in bars, null if unkonwn.
/// </summary>
int? MaxChargeBars { get; }
/// <summary>
/// Holds the maximum chargeing level of the battery in bars, null if unkonwn.
/// </summary>
int? MaxChargeBars { get; }
/// <summary>
/// Holds whether backend is aware of battery charging level.
/// </summary>
bool? IsBackendAccessible { get; }
/// <summary>
/// Holds whether backend is aware of battery charging level.
/// </summary>
bool? IsBackendAccessible { get; }
/// <summary>
/// Holds whether to display battery level or not.
/// </summary>
bool? IsHidden { get; }
}
/// <summary>
/// Holds whether to display battery level or not.
/// </summary>
bool? IsHidden { get; }
}
}

View file

@ -3,60 +3,60 @@ using TINK.Model.Bikes.BikeInfoNS.DriveNS.EngineNS;
namespace TINK.Model.Bikes.BikeInfoNS.DriveNS
{
public enum DriveType
{
/// <summary>
/// Bike without pedalling aid.
/// </summary>
SoleHumanPowered,
public enum DriveType
{
/// <summary>
/// Bike without pedalling aid.
/// </summary>
SoleHumanPowered,
/// <summary>
/// pedal electric cycle: Pedalling is assisted by an electric engine.
/// </summary>
Pedelec
}
/// <summary>
/// pedal electric cycle: Pedalling is assisted by an electric engine.
/// </summary>
Pedelec
}
public class Drive
{
public Drive(
IEngine engine = null,
IBattery battery = null)
{
if (engine == null)
{
Engine = new Engine();
Battery = new Battery.Builder().Build();
Type = DriveType.SoleHumanPowered;
return;
}
public class Drive
{
public Drive(
IEngine engine = null,
IBattery battery = null)
{
if (engine == null)
{
Engine = new Engine();
Battery = new Battery.Builder().Build();
Type = DriveType.SoleHumanPowered;
return;
}
Engine = engine;
Battery = battery ?? new Battery.Builder().Build();
Type = DriveType.Pedelec;
}
Engine = engine;
Battery = battery ?? new Battery.Builder().Build();
Type = DriveType.Pedelec;
}
/// <summary>
/// Gets the type of the drive.
/// </summary>
public DriveType Type { get; private set; }
/// <summary>
/// Gets the type of the drive.
/// </summary>
public DriveType Type { get; private set; }
/// <summary>
/// Engine driving the bike.
/// </summary>
public IEngine Engine { get; private set; }
/// <summary>
/// Engine driving the bike.
/// </summary>
public IEngine Engine { get; private set; }
/// <summary>
/// Battery powering the engine.
/// </summary>
public IBattery _Battery = new Battery.Builder().Build();
/// <summary>
/// Battery powering the engine.
/// </summary>
public IBattery _Battery = new Battery.Builder().Build();
/// <summary>
/// Battery powering the engine.
/// </summary>
public IBattery Battery
{
get => _Battery;
set => _Battery = value ?? new Battery.Builder().Build();
}
}
/// <summary>
/// Battery powering the engine.
/// </summary>
public IBattery Battery
{
get => _Battery;
set => _Battery = value ?? new Battery.Builder().Build();
}
}
}

View file

@ -1,13 +1,13 @@
namespace TINK.Model.Bikes.BikeInfoNS.DriveNS.EngineNS
{
public class Engine : IEngine
{
public Engine(string manufacturer = null)
=> Manufacturer = !string.IsNullOrEmpty(manufacturer) ? manufacturer : null;
public class Engine : IEngine
{
public Engine(string manufacturer = null)
=> Manufacturer = !string.IsNullOrEmpty(manufacturer) ? manufacturer : null;
/// <summary>
/// Manufacturer of the engine.
/// </summary>
public string Manufacturer { get; private set; } = null;
}
/// <summary>
/// Manufacturer of the engine.
/// </summary>
public string Manufacturer { get; private set; } = null;
}
}

View file

@ -1,10 +1,10 @@
namespace TINK.Model.Bikes.BikeInfoNS.DriveNS.EngineNS
{
public interface IEngine
{
/// <summary>
/// Manufacturer of the engine.
/// </summary>
string Manufacturer { get; }
}
public interface IEngine
{
/// <summary>
/// Manufacturer of the engine.
/// </summary>
string Manufacturer { get; }
}
}

View file

@ -3,21 +3,21 @@ using TINK.Model.Bikes.BikeInfoNS.DriveNS.EngineNS;
namespace TINK.Model.Bikes.BikeInfoNS
{
public interface IDrive
{
/// <summary>
/// Gets the type of the drive.
/// </summary>
DriveNS.DriveType Type { get; }
public interface IDrive
{
/// <summary>
/// Gets the type of the drive.
/// </summary>
DriveNS.DriveType Type { get; }
/// <summary>
/// Engine driving the bike.
/// </summary>
IEngine Engine { get; }
/// <summary>
/// Engine driving the bike.
/// </summary>
IEngine Engine { get; }
/// <summary>
/// Battery powering the engine.
/// </summary>
IBattery Battery { get; }
}
/// <summary>
/// Battery powering the engine.
/// </summary>
IBattery Battery { get; }
}
}

View file

@ -2,46 +2,46 @@
namespace TINK.Model.Bikes.BikeInfoNS
{
/// <summary>
/// Successor of TarifDescription- object.
/// Manages tariff- and rental info.
/// </summary>
public class RentalDescription
{
/// <summary>
/// The different elements of a tariff (example: "Max Gebühr", )
/// </summary>
public class TariffElement
{
/// <summary>
/// Describes the tariff element. To be displayed to user (example of elements: "Gratis Mietzeit", "Mietgebühr", "Max Gebühr").
/// </summary>
public string Description { get; set; } = string.Empty;
/// <summary>
/// Successor of TarifDescription- object.
/// Manages tariff- and rental info.
/// </summary>
public class RentalDescription
{
/// <summary>
/// The different elements of a tariff (example: "Max Gebühr", )
/// </summary>
public class TariffElement
{
/// <summary>
/// Describes the tariff element. To be displayed to user (example of elements: "Gratis Mietzeit", "Mietgebühr", "Max Gebühr").
/// </summary>
public string Description { get; set; } = string.Empty;
/// <summary>
/// Holds the tariff element value. To be displayed to user (example: "9.00 € / Tag").
/// </summary>
public string Value { get; set; } = string.Empty;
}
/// <summary>
/// Holds the tariff element value. To be displayed to user (example: "9.00 € / Tag").
/// </summary>
public string Value { get; set; } = string.Empty;
}
public class InfoElement
{
public string Key { get; set; }
public string Value { get; set; }
}
public class InfoElement
{
public string Key { get; set; }
public string Value { get; set; }
}
/// <summary>
/// Name of the tariff.
/// </summary>
public string Name { get; set; } = string.Empty;
/// <summary>
/// Name of the tariff.
/// </summary>
public string Name { get; set; } = string.Empty;
/// <summary>
/// Number of the tariff.
/// </summary>
public int? Id { get; set; }
/// <summary>
/// Number of the tariff.
/// </summary>
public int? Id { get; set; }
public Dictionary<string, TariffElement> TariffEntries { get; set; } = new Dictionary<string, TariffElement>();
public Dictionary<string, TariffElement> TariffEntries { get; set; } = new Dictionary<string, TariffElement>();
public Dictionary<string, InfoElement> InfoEntries { get; set; } = new Dictionary<string, InfoElement>();
}
public Dictionary<string, InfoElement> InfoEntries { get; set; } = new Dictionary<string, InfoElement>();
}
}

View file

@ -2,9 +2,9 @@
namespace TINK.Model.Bikes.BikeInfoNS
{
/// <summary>
/// Holds tariff info for a single bike.
/// </summary>
/// <summary>
/// Holds tariff info for a single bike.
/// </summary>
#if USCSHARP9
public record TariffDescription
{
@ -39,44 +39,44 @@ namespace TINK.Model.Bikes.BikeInfoNS
public double MaxFeeEuroPerDay { get; init; }
}
#else
public class TariffDescription
{
/// <summary>
/// Name of the tariff.
/// </summary>
public string Name { get; set; }
public class TariffDescription
{
/// <summary>
/// Name of the tariff.
/// </summary>
public string Name { get; set; }
/// <summary>
/// Number of the tariff.
/// </summary>
public int? Number { get; set; }
/// <summary>
/// Number of the tariff.
/// </summary>
public int? Number { get; set; }
/// <summary>
/// Costs per hour in euro.
/// </summary>
public double FeeEuroPerHour { get; set; }
/// <summary>
/// Costs per hour in euro.
/// </summary>
public double FeeEuroPerHour { get; set; }
/// <summary>
/// Costs of the abo per month.
/// </summary>
public double AboEuroPerMonth { get; set; }
/// <summary>
/// Costs of the abo per month.
/// </summary>
public double AboEuroPerMonth { get; set; }
/// <summary>
/// Costs per hour in euro.
/// </summary>
public TimeSpan FreeTimePerSession { get; set; }
/// <summary>
/// Costs per hour in euro.
/// </summary>
public TimeSpan FreeTimePerSession { get; set; }
/// <summary>
/// Max. costs per day in euro.
/// </summary>
public double MaxFeeEuroPerDay { get; set; }
/// <summary>
/// Max. costs per day in euro.
/// </summary>
public double MaxFeeEuroPerDay { get; set; }
/// <summary> Info about operator agb as HTML (i.g. text and hyperlink). </summary>
public string OperatorAgb { get; set; }
/// <summary> Info about operator agb as HTML (i.g. text and hyperlink). </summary>
public string OperatorAgb { get; set; }
/// <summary> Text which informs users about GPS tracking if tracking is on. </summary>
public string TrackingInfo { get; set; }
/// <summary> Text which informs users about GPS tracking if tracking is on. </summary>
public string TrackingInfo { get; set; }
}
}
#endif
}