forked from BeyondDimension/SteamTools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOpenSourceLibrary.cs
More file actions
124 lines (105 loc) · 5.1 KB
/
OpenSourceLibrary.cs
File metadata and controls
124 lines (105 loc) · 5.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
using MessagePack;
using System.Collections.Generic;
using System.Text;
namespace System.Application.Models
{
[MessagePackObject(keyAsPropertyName: true)]
public sealed partial class OpenSourceLibrary
{
public string? Name { get; set; }
public string? Url { get; set; }
public string? License { get; set; }
public string? LicenseUrl { get; set; }
public string? LicenseText { get; set; }
public string? Copyright { get; set; }
const string hr = "-----------------------------------";
static StringBuilder ToString(OpenSourceLibrary m, StringBuilder sb)
{
sb.AppendLine(hr);
sb.AppendLine(m.Name);
sb.AppendLine(hr);
sb.AppendLine(m.Url);
if (m.Url != null)
{
if (corrections.ContainsKey(m.Url))
{
var (license, copyright) = corrections[m.Url];
if (!string.IsNullOrWhiteSpace(license)) m.License = license;
if (!string.IsNullOrWhiteSpace(copyright)) m.Copyright = copyright;
}
if (string.IsNullOrWhiteSpace(m.Copyright) && m.Url.StartsWith("https://github.com", StringComparison.OrdinalIgnoreCase))
{
var urlSplitArray = m.Url.Split('/', StringSplitOptions.RemoveEmptyEntries);
if (urlSplitArray.Length >= 3)
{
m.Copyright = $"Copyright (c) {urlSplitArray[2]}";
}
}
}
if (!string.IsNullOrWhiteSpace(m.Copyright) && !string.IsNullOrWhiteSpace(m.License) && !string.IsNullOrWhiteSpace(m.LicenseUrl) && !string.Equals("NOASSERTION", m.License, StringComparison.OrdinalIgnoreCase))
{
sb.AppendLine();
sb.AppendLine(m.Copyright);
sb.AppendLine();
sb.AppendFormat("Licensed under the {0};{1}{2}", m.License, Environment.NewLine, m.LicenseUrl);
sb.AppendLine();
}
else if (!string.IsNullOrEmpty(m.LicenseText))
{
sb.AppendLine();
sb.AppendLine(m.LicenseText);
}
return sb;
}
public static string ToString(IEnumerable<OpenSourceLibrary> items, StringBuilder? sb = null)
{
sb ??= new StringBuilder();
foreach (var item in items)
{
ToString(item, sb);
sb.AppendLine();
}
return sb.ToString();
}
public override string ToString() => ToString(this, new StringBuilder()).ToString();
static readonly IReadOnlyDictionary<string, (string license, string copyright)> corrections = new Dictionary<string, (string license, string copyright)>
{
// https://api.github.com/licenses
{ "https://github.com/runceel/Livet", ("Zlib", "") },
{ "https://github.com/ninject/Ninject", ("Apache-2.0", "") },
{ "https://github.com/apache/logging-log4net", ("Apache-2.0", "Copyright (c) The Apache Software Foundation") },
{ "https://github.com/JustArchiNET/ArchiSteamFarm", ("Apache-2.0", "") },
{ "https://github.com/winauth/winauth", ("GPL-3.0", "") },
{ "https://github.com/MichaCo/DnsClient.NET", ("Apache-2.0", "") },
{ "https://github.com/neuecc/MessagePack-CSharp", ("MIT", "") },
{ "https://github.com/gfoidl/Base64", ("MIT", "") },
{ "https://github.com/App-vNext/Polly", ("BSD-3-Clause", "") },
{ "https://github.com/icsharpcode/SharpZipLib", ("MIT", "") },
{ "https://github.com/chromiumembedded/cef", ("BSD-licensed", "") },
{ "https://github.com/cefsharp/CefSharp", ("BSD-3-Clause", "") },
{ "https://github.com/xamarin/essentials", ("MIT", "") },
{ "https://github.com/dotnet/efcore", ("Apache-2.0", "Copyright (c) .NET Foundation and Contributors") },
{ "https://github.com/dotnet/aspnetcore", ("Apache-2.0", "Copyright (c) .NET Foundation and Contributors") },
{ "https://github.com/dotnet/runtime", ("MIT", "") },
{ "https://github.com/ant-design-blazor/ant-design-blazor", ("MIT", "") },
{ "https://github.com/microsoft/appcenter-sdk-dotnet", ("MIT", "") },
{ "https://github.com/nor0x/AppCenter-XMac", ("MIT", "") },
{ "https://github.com/moq/moq4", ("BSD-3-Clause", "") },
{ "https://github.com/xamarin/Xamarin.Forms", ("MIT", "") },
{ "https://github.com/novotnyllc/bc-csharp", ("MIT", "") },
//{ "", ("", "") },
};
}
#if DEBUG
[Obsolete("待定", true)]
public static partial class ProductInfo
{
[Obsolete("use System.Application.Models.OpenSourceLibrary", true)]
public class Library
{
}
[Obsolete("use System.Application.Models.OpenSourceLibrary.Values/StringValues", true)]
public static IReadOnlyCollection<Library> Libraries => throw new NotImplementedException();
}
#endif
}