feat(decode): Methoden zur Konvertierung des dekodierten Arrays in eine Umschlag-Empfänger-ID und eine Nur-Lese-ID mit Ausnahmewirkung hinzugefügt.
This commit is contained in:
parent
6847b74095
commit
792aa0b922
@ -1,5 +1,4 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System.Security.Cryptography;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Application
|
namespace EnvelopeGenerator.Application
|
||||||
@ -81,13 +80,23 @@ namespace EnvelopeGenerator.Application
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EncodeType GetEncodeType(string[] decoded) => decoded.Length switch
|
public static EncodeType GetEncodeType(this string[] decoded) => decoded.Length switch
|
||||||
{
|
{
|
||||||
2 => EncodeType.EnvelopeReceiver,
|
2 => EncodeType.EnvelopeReceiver,
|
||||||
3 => EncodeType.ReadOnly,
|
3 => long.TryParse(decoded[1], out var _) ? EncodeType.ReadOnly : EncodeType.Undefined,
|
||||||
_ => EncodeType.Undefined,
|
_ => EncodeType.Undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public static (string? EnvelopeUuid, string? ReceiverSignature) ToEnvelopeReceiverId(this string[] decoded)
|
||||||
|
=> decoded.GetEncodeType() == EncodeType.EnvelopeReceiver
|
||||||
|
? (EnvelopeUuid: decoded[0], ReceiverSignature: decoded[1])
|
||||||
|
: throw new InvalidOperationException("Attempted to convert a decoded other than type EnvelopeReceiver to EnvelopeReceiver. ");
|
||||||
|
|
||||||
|
public static long ToReadOnlyId(this string[] decoded)
|
||||||
|
=> decoded.GetEncodeType() == EncodeType.ReadOnly
|
||||||
|
? long.Parse(decoded[1])
|
||||||
|
: throw new InvalidOperationException("Attempted to convert a decoded other than type EnvelopeReceiver to EnvelopeReceiver. ");
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Decodes the envelope receiver ID and extracts the envelope UUID and receiver signature.
|
/// Decodes the envelope receiver ID and extracts the envelope UUID and receiver signature.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user