iface & doi

This commit is contained in:
femsci 2023-12-11 12:00:41 +01:00
parent 1b4f5bf782
commit 4279114543
Signed by: femsci
GPG key ID: 08F7911F0E650C67
2 changed files with 22 additions and 1 deletions

View file

@ -11,7 +11,14 @@ public readonly struct Doi
try
{
Prefix = short.Parse(match.Groups["prefix"].Value);
Suffix = match.Groups["suffix"].Value;
if (Prefix > 1000 && Prefix < 10000)
{
Suffix = match.Groups["suffix"].Value;
}
else
{
throw new();
}
}
catch (Exception)
{
@ -19,6 +26,17 @@ public readonly struct Doi
}
}
public Doi(short prefix, string suffix)
{
if (prefix > 1000 && prefix < 10000)
{
Prefix = prefix;
Suffix = suffix;
return;
}
throw new ArgumentException($"Invalid prefix: {prefix}");
}
public short Prefix { get; }
public string Suffix { get; }

View file

@ -1,6 +1,9 @@
using System.Net;
namespace Nyanlabs.Pubresolv;
public interface IResolver
{
public Task Resolve(Doi doi);
public Task<bool> Authenticate(ICredentials credentials);
}