mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2024-12-23 15:46:29 +01:00
70 lines
1.9 KiB
C#
70 lines
1.9 KiB
C#
|
using Newtonsoft.Json;
|
|||
|
|
|||
|
namespace TINK.Model.Bikes.BikeInfoNS.BluetoothLock
|
|||
|
{
|
|||
|
public class VersionInfo : IVersionInfo
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// Holds info about firmware- and hardware version of a lock and the type of lock (lock version).
|
|||
|
/// </summary>
|
|||
|
private VersionInfo() { }
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// Holds the firmware version of the lock.
|
|||
|
/// </summary>
|
|||
|
public int FirmwareVersion { get; private set; } = 0;
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// Holds the hardware version (revision) of the lock.
|
|||
|
/// </summary>
|
|||
|
public int HardwareVersion { get; private set; } = 0;
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// Holds lock version (2 – classic, 3 – plus, 4 – GPS).
|
|||
|
/// </summary>
|
|||
|
public int LockVersion { get; private set; } = 0;
|
|||
|
|
|||
|
public override bool Equals(object obj)
|
|||
|
=> Equals(obj as VersionInfo);
|
|||
|
|
|||
|
public bool Equals(VersionInfo other)
|
|||
|
{
|
|||
|
if (ReferenceEquals(other, null)) return false;
|
|||
|
if (ReferenceEquals(this, other)) return true;
|
|||
|
if (GetType() != other.GetType()) return false;
|
|||
|
|
|||
|
return ToString() == other.ToString();
|
|||
|
}
|
|||
|
|
|||
|
public override int GetHashCode() => ToString().GetHashCode();
|
|||
|
|
|||
|
public override string ToString() => JsonConvert.SerializeObject(this);
|
|||
|
|
|||
|
public static bool operator ==(VersionInfo lhs, VersionInfo rhs)
|
|||
|
{
|
|||
|
if (ReferenceEquals(lhs, null))
|
|||
|
return ReferenceEquals(rhs, null) ? true /*null == null = true*/: false;
|
|||
|
|
|||
|
return lhs.Equals(rhs);
|
|||
|
}
|
|||
|
|
|||
|
public static bool operator !=(VersionInfo lhs, VersionInfo rhs)
|
|||
|
=> !(lhs == rhs);
|
|||
|
public class Builder
|
|||
|
{
|
|||
|
private VersionInfo versionInfo = new VersionInfo();
|
|||
|
|
|||
|
public int FirmwareVersion { get => versionInfo.FirmwareVersion; set => versionInfo.FirmwareVersion = value; }
|
|||
|
|
|||
|
public int HardwareVersion { get => versionInfo.HardwareVersion; set => versionInfo.HardwareVersion = value; }
|
|||
|
|
|||
|
public int LockVersion { get => versionInfo.LockVersion; set => versionInfo.LockVersion = value; }
|
|||
|
|
|||
|
public VersionInfo Build()
|
|||
|
{
|
|||
|
return versionInfo;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|