Skip to content

Commit cc8efea

Browse files
committed
add more formats
1 parent ba93e39 commit cc8efea

File tree

7 files changed

+1231
-3
lines changed

7 files changed

+1231
-3
lines changed

MimeTypeCore/MimeTypeCore.Formatter/Program.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace MimeTypeCore.Formatter;
1+
using System.Runtime.CompilerServices;
2+
3+
namespace MimeTypeCore.Formatter;
24

35
class Program
46
{
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<LangVersion>preview</LangVersion>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<ProjectReference Include="..\MimeTypeCore\MimeTypeCore.csproj" />
13+
</ItemGroup>
14+
15+
<ItemGroup>
16+
<None Update="input.txt">
17+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
18+
</None>
19+
</ItemGroup>
20+
21+
<ItemGroup>
22+
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
23+
</ItemGroup>
24+
25+
</Project>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using System.Text;
2+
using Newtonsoft.Json;
3+
4+
namespace MimeTypeCore.Inserter;
5+
6+
class Program
7+
{
8+
static void Main(string[] args)
9+
{
10+
Dictionary<string, string> source = JsonConvert.DeserializeObject<Dictionary<string, string>>(File.ReadAllText("input.txt"))!;
11+
Dictionary<string, string> compareTo = MimeTypeMapMapping.Mappings;
12+
13+
List<KeyValuePair<string, string>> add = [];
14+
15+
foreach (KeyValuePair<string, string> str in source)
16+
{
17+
string key = $".{str.Key}";
18+
19+
if (!compareTo.TryGetValue(key, out _))
20+
{
21+
add.Add(str);
22+
}
23+
}
24+
25+
if (File.Exists("output.txt"))
26+
{
27+
File.Delete("output.txt");
28+
}
29+
30+
StringBuilder sb = new StringBuilder();
31+
foreach (KeyValuePair<string, string> x in add)
32+
{
33+
sb.AppendLine($"{{ \".{x.Key}\", \"{x.Value}\" }},");
34+
}
35+
36+
File.WriteAllText("output.txt", sb.ToString().Trim());
37+
}
38+
}

0 commit comments

Comments
 (0)