2024-04-05 11:18:43 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2024-04-06 20:35:21 +08:00
|
|
|
|
using System.IO;
|
2024-04-05 11:59:38 +08:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
2024-04-05 11:18:43 +08:00
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
|
|
|
|
namespace SicSetupMaker.ReleaseNoteSupport
|
|
|
|
|
{
|
|
|
|
|
public class Notes
|
|
|
|
|
{
|
|
|
|
|
#region Constructors
|
|
|
|
|
|
|
|
|
|
public Notes()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-06 20:35:21 +08:00
|
|
|
|
public Notes(string features, string bugsFixed)
|
|
|
|
|
{
|
|
|
|
|
Features = FromText(features);
|
|
|
|
|
BugFixed = FromText(bugsFixed);
|
|
|
|
|
RawJson = ToJsonString();
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-05 11:18:43 +08:00
|
|
|
|
public Notes(IEnumerable<string> features, IEnumerable<string> bugFixed)
|
|
|
|
|
{
|
|
|
|
|
Features = features;
|
|
|
|
|
BugFixed = bugFixed;
|
2024-04-06 20:35:21 +08:00
|
|
|
|
RawJson = ToJsonString();
|
2024-04-05 11:18:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Notes(string jsonString)
|
|
|
|
|
{
|
|
|
|
|
RawJson = jsonString;
|
|
|
|
|
dynamic jNote = JsonConvert.DeserializeObject(RawJson);
|
|
|
|
|
Features = jNote?.feats ?? Array.Empty<string>();
|
|
|
|
|
BugFixed = jNote?.@fixed ?? Array.Empty<string>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Properties
|
|
|
|
|
|
2024-04-06 20:35:21 +08:00
|
|
|
|
[JsonIgnore]
|
|
|
|
|
public string RawJson { get; private set; }
|
2024-04-05 11:18:43 +08:00
|
|
|
|
|
|
|
|
|
[JsonProperty("feat")]
|
|
|
|
|
public IEnumerable<string> Features { get; set; }
|
|
|
|
|
|
|
|
|
|
[JsonProperty("fixed")]
|
|
|
|
|
public IEnumerable<string> BugFixed { get; set;}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Methods
|
|
|
|
|
|
2024-04-06 20:35:21 +08:00
|
|
|
|
private IEnumerable<string> FromText(string content)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(content))
|
|
|
|
|
return Array.Empty<string>();
|
|
|
|
|
var list = new List<string>();
|
|
|
|
|
using (var reader = new StringReader(content))
|
|
|
|
|
{
|
|
|
|
|
while (reader.ReadLine() is { } item)
|
|
|
|
|
{
|
|
|
|
|
if(!string.IsNullOrEmpty(item))
|
|
|
|
|
list.Add(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return [.. list];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string ToJsonString()
|
2024-04-05 11:18:43 +08:00
|
|
|
|
{
|
|
|
|
|
return JsonConvert.SerializeObject(this, Formatting.Indented);
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-05 11:59:38 +08:00
|
|
|
|
public string ToMarkDown()
|
|
|
|
|
{
|
|
|
|
|
var sb = new StringBuilder();
|
|
|
|
|
sb.AppendLine("- Bug修复");
|
|
|
|
|
if (BugFixed.Any())
|
|
|
|
|
BugFixed.ToList().ForEach(x => sb.AppendLine($"\t- {x}"));
|
|
|
|
|
else
|
|
|
|
|
sb.AppendLine($"\t- 无");
|
|
|
|
|
|
|
|
|
|
sb.AppendLine("- 新特性");
|
|
|
|
|
if (Features.Any())
|
|
|
|
|
Features.ToList().ForEach(x => sb.AppendLine($"\t- {x}"));
|
|
|
|
|
else
|
|
|
|
|
sb.AppendLine($"\t- 无");
|
|
|
|
|
|
|
|
|
|
return sb.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
return $"{Features} features, {BugFixed} bugs fixed";
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-05 11:18:43 +08:00
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|