init; VCF
This commit is contained in:
commit
ce4eeccd54
4 changed files with 166 additions and 0 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
**/obj/
|
||||
**/bin/
|
27
Nyanbyte.IDShare.sln
Normal file
27
Nyanbyte.IDShare.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", "{3E1B6FBD-3EAA-4729-B808-0E6B2BCDB7A7}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nyanbyte.IDShare.Vcf", "src\Nyanbyte.IDShare.Vcf\Nyanbyte.IDShare.Vcf.csproj", "{8696BF96-C969-4A1B-B1D1-A4BA47634DEA}"
|
||||
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
|
||||
{8696BF96-C969-4A1B-B1D1-A4BA47634DEA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{8696BF96-C969-4A1B-B1D1-A4BA47634DEA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{8696BF96-C969-4A1B-B1D1-A4BA47634DEA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{8696BF96-C969-4A1B-B1D1-A4BA47634DEA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{8696BF96-C969-4A1B-B1D1-A4BA47634DEA} = {3E1B6FBD-3EAA-4729-B808-0E6B2BCDB7A7}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
9
src/Nyanbyte.IDShare.Vcf/Nyanbyte.IDShare.Vcf.csproj
Normal file
9
src/Nyanbyte.IDShare.Vcf/Nyanbyte.IDShare.Vcf.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>
|
128
src/Nyanbyte.IDShare.Vcf/Vcard.cs
Normal file
128
src/Nyanbyte.IDShare.Vcf/Vcard.cs
Normal file
|
@ -0,0 +1,128 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Nyanbyte.IDShare.Vcf;
|
||||
|
||||
public class Vcard
|
||||
{
|
||||
|
||||
public DateTime? Birthday { get; set; }
|
||||
|
||||
public static Vcard FromString(string data)
|
||||
{
|
||||
data = data.Trim();
|
||||
|
||||
string[] lines = data.Split('\n');
|
||||
|
||||
if (lines.Length < 3)
|
||||
{
|
||||
throw new ArgumentException("Invalid data.");
|
||||
}
|
||||
|
||||
if (lines[0] != "BEGIN:VCARD" || lines[^1] != "END:VCARD")
|
||||
{
|
||||
throw new ArgumentException("Not a proper VCF format.");
|
||||
}
|
||||
|
||||
if (lines[1] != "VERSION:4.0")
|
||||
{
|
||||
throw new ArgumentException("Invalid data: This implementation supports only VCF version 4.0.");
|
||||
}
|
||||
|
||||
foreach (string line in lines[2..^2])
|
||||
{
|
||||
string keyword = line[..line.IndexOf(':')];
|
||||
string? type = null;
|
||||
if (keyword.Contains(';'))
|
||||
{
|
||||
type = keyword[(keyword.IndexOf(';') + 1)..];
|
||||
keyword = keyword[..keyword.IndexOf(';')];
|
||||
}
|
||||
|
||||
switch (keyword)
|
||||
{
|
||||
case "ADR":
|
||||
NotImplemented();
|
||||
break;
|
||||
case "BDAY":
|
||||
NotImplemented();
|
||||
break;
|
||||
case "CATEGORIES":
|
||||
NotImplemented();
|
||||
break;
|
||||
case "EMAIL":
|
||||
NotImplemented();
|
||||
break;
|
||||
case "FN":
|
||||
NotImplemented();
|
||||
break;
|
||||
case "GENDER":
|
||||
NotImplemented();
|
||||
break;
|
||||
case "KEY":
|
||||
NotImplemented();
|
||||
break;
|
||||
case "KIND":
|
||||
NotImplemented();
|
||||
break;
|
||||
case "LOGO":
|
||||
NotImplemented();
|
||||
break;
|
||||
case "N":
|
||||
NotImplemented();
|
||||
break;
|
||||
case "NICKNAME":
|
||||
NotImplemented();
|
||||
break;
|
||||
case "NOTE":
|
||||
NotImplemented();
|
||||
break;
|
||||
case "ORG":
|
||||
NotImplemented();
|
||||
break;
|
||||
case "PHOTO":
|
||||
NotImplemented();
|
||||
break;
|
||||
case "REV":
|
||||
NotImplemented();
|
||||
break;
|
||||
case "ROLE":
|
||||
NotImplemented();
|
||||
break;
|
||||
case "TEL":
|
||||
NotImplemented();
|
||||
break;
|
||||
case "TITLE":
|
||||
NotImplemented();
|
||||
break;
|
||||
case "TZ":
|
||||
NotImplemented();
|
||||
break;
|
||||
case "URL":
|
||||
NotImplemented();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private static void NotImplemented()
|
||||
{
|
||||
//nimpl or msg
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
StringBuilder sb = new("BEGIN:VCARD\nVERSION:4.0;\n");
|
||||
|
||||
throw new NotImplementedException();
|
||||
|
||||
sb.Append("END:VCARD");
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue