skel
This commit is contained in:
commit
1b4f5bf782
7 changed files with 92 additions and 0 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
**/obj/
|
||||
**/bin/
|
27
Nyanlabs.Pubresolv.sln
Normal file
27
Nyanlabs.Pubresolv.sln
Normal file
|
@ -0,0 +1,27 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.0.31903.59
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{66E15B3B-99D3-4443-A623-359B0C4EEBD6}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nyanlabs.Pubresolv", "src\Nyanlabs.Pubresolv\Nyanlabs.Pubresolv.csproj", "{1F6A79FC-2745-4421-B329-A956E4B9E671}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{1F6A79FC-2745-4421-B329-A956E4B9E671}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1F6A79FC-2745-4421-B329-A956E4B9E671}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1F6A79FC-2745-4421-B329-A956E4B9E671}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1F6A79FC-2745-4421-B329-A956E4B9E671}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{1F6A79FC-2745-4421-B329-A956E4B9E671} = {66E15B3B-99D3-4443-A623-359B0C4EEBD6}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
3
README.md
Normal file
3
README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
# pubresolv
|
||||
|
||||
Scientific document resolver for academic proxies
|
36
src/Nyanlabs.Pubresolv/Doi.cs
Normal file
36
src/Nyanlabs.Pubresolv/Doi.cs
Normal file
|
@ -0,0 +1,36 @@
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Nyanlabs.Pubresolv;
|
||||
|
||||
public readonly struct Doi
|
||||
{
|
||||
public Doi(string doi)
|
||||
{
|
||||
var match = Regex.Match(doi, @"^10\.(?<prefix>\d{4})\/(?<suffix>.*)$", RegexOptions.Compiled);
|
||||
try
|
||||
{
|
||||
Prefix = short.Parse(match.Groups["prefix"].Value);
|
||||
Suffix = match.Groups["suffix"].Value;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw new ArgumentException($"Invalid DOI string: {doi}");
|
||||
}
|
||||
}
|
||||
|
||||
public short Prefix { get; }
|
||||
public string Suffix { get; }
|
||||
|
||||
public override readonly string ToString() => $"10.{Prefix}/{Suffix}";
|
||||
public override readonly bool Equals([NotNullWhen(true)] object? obj)
|
||||
{
|
||||
return obj is Doi doi && doi.Prefix == Prefix && doi.Suffix == Suffix;
|
||||
}
|
||||
|
||||
public static bool operator ==(Doi left, Doi right) => left.Equals(right);
|
||||
|
||||
public static bool operator !=(Doi left, Doi right) => !(left == right);
|
||||
|
||||
public override int GetHashCode() => HashCode.Combine(Prefix, Suffix);
|
||||
}
|
6
src/Nyanlabs.Pubresolv/IResolver.cs
Normal file
6
src/Nyanlabs.Pubresolv/IResolver.cs
Normal file
|
@ -0,0 +1,6 @@
|
|||
namespace Nyanlabs.Pubresolv;
|
||||
|
||||
public interface IResolver
|
||||
{
|
||||
public Task Resolve(Doi doi);
|
||||
}
|
9
src/Nyanlabs.Pubresolv/Nyanlabs.Pubresolv.csproj
Normal file
9
src/Nyanlabs.Pubresolv/Nyanlabs.Pubresolv.csproj
Normal file
|
@ -0,0 +1,9 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
9
src/Nyanlabs.Pubresolv/Pubresolv.cs
Normal file
9
src/Nyanlabs.Pubresolv/Pubresolv.cs
Normal file
|
@ -0,0 +1,9 @@
|
|||
namespace Nyanlabs.Pubresolv;
|
||||
|
||||
public class Pubresolv
|
||||
{
|
||||
public ICollection<IResolver> GetResolvers()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue