mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-04-22 21:06:30 +02:00
Initial version.
This commit is contained in:
commit
6bab491a21
40 changed files with 1812 additions and 0 deletions
32
LockItShared/Model/Connector/TextToLockItTypeHelper.cs
Normal file
32
LockItShared/Model/Connector/TextToLockItTypeHelper.cs
Normal file
|
@ -0,0 +1,32 @@
|
|||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace TINK.Model.Connector
|
||||
{
|
||||
public static class TextToLockItTypeHelper
|
||||
{
|
||||
/// <summary> Lock id which representing a non valid id. </summary>
|
||||
public const int INVALIDLOCKID = 0;
|
||||
|
||||
/// <summary> Lock GUID which representing a non valid id. </summary>
|
||||
public readonly static Guid INVALIDLOCKGUID = new Guid();
|
||||
|
||||
/// <summary> First part of advertisement name.</summary>
|
||||
public static string ISHAREITADVERTISMENTTITLE = "ISHAREIT";
|
||||
|
||||
/// <summary> Gets the ID part from advertisment name. </summary>
|
||||
/// <remarks> Advertisement name is made up of name plus separator (+ or -) and a ID</remarks>
|
||||
/// <param name="advertisementName">Advertisment name to extract info from.</param>
|
||||
/// <returns>From information.</returns>
|
||||
public static int GetBluetoothLockId(this string advertisementName)
|
||||
{
|
||||
var name = advertisementName?.ToUpper();
|
||||
if (string.IsNullOrEmpty(name))
|
||||
return INVALIDLOCKID;
|
||||
|
||||
return int.TryParse(Regex.Replace(advertisementName, $"{ISHAREITADVERTISMENTTITLE}[\\-,\\+ ]", ""), out int lockId)
|
||||
? lockId
|
||||
: INVALIDLOCKID;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue