mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-04-20 03:56:29 +02:00
Version 3.0.294
This commit is contained in:
parent
d92fb4a40f
commit
8f40f2c208
133 changed files with 17890 additions and 14246 deletions
8
LockItShared/Model/Bikes/Bike/CopriLock/ILockInfo.cs
Normal file
8
LockItShared/Model/Bikes/Bike/CopriLock/ILockInfo.cs
Normal file
|
@ -0,0 +1,8 @@
|
|||
namespace TINK.Model.Bikes.Bike.CopriLock
|
||||
{
|
||||
public interface ILockInfo
|
||||
{
|
||||
/// <summary> Locking state of backend lock. </summary>
|
||||
LockingState State { get; }
|
||||
}
|
||||
}
|
88
LockItShared/Model/Bikes/Bike/CopriLock/LockInfo.cs
Normal file
88
LockItShared/Model/Bikes/Bike/CopriLock/LockInfo.cs
Normal file
|
@ -0,0 +1,88 @@
|
|||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace TINK.Model.Bikes.Bike.CopriLock
|
||||
{
|
||||
/// <summary> Locking states. </summary>
|
||||
public enum LockingState
|
||||
{
|
||||
/// <summary> App is not connected to lock.</summary>
|
||||
UnknownDisconnected,
|
||||
|
||||
/// <summary> Lock is closed. </summary>
|
||||
Closed,
|
||||
|
||||
/// <summary> Lock is closing. </summary>
|
||||
Closing,
|
||||
|
||||
/// <summary> Lock is open. </summary>
|
||||
Open,
|
||||
|
||||
/// <summary> Lock is opening. </summary>
|
||||
Opening
|
||||
}
|
||||
|
||||
[DataContract]
|
||||
public class LockInfo : ILockInfo
|
||||
{
|
||||
/// <summary> Locking state of bluetooth lock. </summary>
|
||||
[DataMember]
|
||||
public LockingState State { get; private set; } = LockingState.UnknownDisconnected;
|
||||
|
||||
public override bool Equals(object obj) => this.Equals(obj as LockInfo);
|
||||
|
||||
public bool Equals(LockInfo other)
|
||||
{
|
||||
if (Object.ReferenceEquals(other, null)) return false;
|
||||
if (Object.ReferenceEquals(this, other)) return true;
|
||||
if (this.GetType() != other.GetType()) return false;
|
||||
|
||||
return ToString() == other.ToString();
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return ToString().GetHashCode();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
|
||||
public static bool operator ==(LockInfo lhs, LockInfo rhs)
|
||||
{
|
||||
if (Object.ReferenceEquals(lhs, null))
|
||||
return Object.ReferenceEquals(rhs, null) ? true /*null == null = true*/: false;
|
||||
|
||||
return lhs.Equals(rhs);
|
||||
}
|
||||
|
||||
public static bool operator !=(LockInfo lhs, LockInfo rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
public class Builder
|
||||
{
|
||||
public Builder(LockInfo lockInfo = null)
|
||||
{
|
||||
if (lockInfo == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
LockInfo = JsonConvert.DeserializeObject<LockInfo>(JsonConvert.SerializeObject(lockInfo));
|
||||
}
|
||||
|
||||
private readonly LockInfo LockInfo = new LockInfo();
|
||||
|
||||
|
||||
public LockingState State { get => LockInfo.State; set => LockInfo.State = value; }
|
||||
|
||||
public LockInfo Build() => LockInfo;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue