sharee.bike-App/TINKLib/Model/Bikes/BikeInfoNS/BluetoothLock/VersionInfo.cs
2022-09-20 13:51:55 +02:00

69 lines
1.9 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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;
}
}
}
}