mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-21 14:04:12 +01:00
Comparable WalletId
This commit is contained in:
parent
a28814bc0e
commit
3c58bff803
1 changed files with 31 additions and 0 deletions
|
@ -11,6 +11,8 @@ namespace BTCPayServer
|
|||
static readonly Regex _WalletStoreRegex = new Regex("^S-([a-zA-Z0-9]{30,60})-([a-zA-Z]{2,5})$");
|
||||
public static bool TryParse(string str, out WalletId walletId)
|
||||
{
|
||||
if (str == null)
|
||||
throw new ArgumentNullException(nameof(str));
|
||||
walletId = null;
|
||||
WalletId w = new WalletId();
|
||||
var match = _WalletStoreRegex.Match(str);
|
||||
|
@ -32,8 +34,37 @@ namespace BTCPayServer
|
|||
}
|
||||
public string StoreId { get; set; }
|
||||
public string CryptoCode { get; set; }
|
||||
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
WalletId item = obj as WalletId;
|
||||
if (item == null)
|
||||
return false;
|
||||
return ToString().Equals(item.ToString(), StringComparison.InvariantCulture);
|
||||
}
|
||||
public static bool operator ==(WalletId a, WalletId b)
|
||||
{
|
||||
if (System.Object.ReferenceEquals(a, b))
|
||||
return true;
|
||||
if (((object)a == null) || ((object)b == null))
|
||||
return false;
|
||||
return a.ToString() == b.ToString();
|
||||
}
|
||||
|
||||
public static bool operator !=(WalletId a, WalletId b)
|
||||
{
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return ToString().GetHashCode(StringComparison.Ordinal);
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
if (StoreId == null || CryptoCode == null)
|
||||
return "";
|
||||
return $"S-{StoreId}-{CryptoCode.ToUpperInvariant()}";
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue