2021-05-13 20:03:07 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace TINK.Model.Bike
|
2022-04-25 22:15:15 +02:00
|
|
|
|
{
|
2021-05-13 20:03:07 +02:00
|
|
|
|
/// <summary> Count of wheels. </summary>
|
|
|
|
|
public enum WheelType
|
|
|
|
|
{
|
|
|
|
|
Mono = 0,
|
|
|
|
|
Two = 1,
|
|
|
|
|
Trike = 2,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary> Type of bike. </summary>
|
|
|
|
|
public enum TypeOfBike
|
|
|
|
|
{
|
|
|
|
|
Allround = 0,
|
|
|
|
|
Cargo = 1,
|
|
|
|
|
Citybike = 2,
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-25 22:15:15 +02:00
|
|
|
|
/// <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.
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-13 20:03:07 +02:00
|
|
|
|
public class Bike : IEquatable<Bike>
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Constructs a bike.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public Bike(
|
2021-06-26 20:57:55 +02:00
|
|
|
|
string p_iId,
|
2022-04-25 22:15:15 +02:00
|
|
|
|
LockModel lockModel,
|
2021-05-13 20:03:07 +02:00
|
|
|
|
WheelType? wheelType = null,
|
|
|
|
|
TypeOfBike? typeOfBike = null,
|
|
|
|
|
string description = null)
|
|
|
|
|
{
|
|
|
|
|
WheelType = wheelType;
|
|
|
|
|
TypeOfBike = typeOfBike;
|
2022-04-25 22:15:15 +02:00
|
|
|
|
LockModel = lockModel;
|
2021-05-13 20:03:07 +02:00
|
|
|
|
Id = p_iId;
|
|
|
|
|
Description = description;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Holds the unique id of the bike;
|
|
|
|
|
/// </summary>
|
2021-06-26 20:57:55 +02:00
|
|
|
|
public string Id { get; }
|
2021-05-13 20:03:07 +02:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Holds the count of wheels.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public WheelType? WheelType { get; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Holds the type of bike.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public TypeOfBike? TypeOfBike { get; }
|
|
|
|
|
|
2022-04-25 22:15:15 +02:00
|
|
|
|
/// <summary> Gets the model of the lock. </summary>
|
|
|
|
|
public LockModel LockModel { get; private set; }
|
|
|
|
|
|
2021-05-13 20:03:07 +02:00
|
|
|
|
/// <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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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> 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 !(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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|