Working a bit

This commit is contained in:
Lani Aung
2021-10-02 15:18:07 -06:00
parent 16599f7df3
commit 66ccf83051
13 changed files with 260 additions and 65 deletions
+36
View File
@@ -0,0 +1,36 @@
using System.Text.RegularExpressions;
namespace fxl.codes.kisekae.Models
{
public class PaletteModel
{
private const string Regex = "%([a-zA-Z0-9\\-]*\\.[kKcCfF]+)[\\s]*;(.*)";
public string FileName { get; }
public string Comment { get; }
public PaletteModel(string line)
{
var matcher = new Regex(Regex);
var match = matcher.Match(line);
foreach (var group in matcher.GetGroupNames())
{
if (group == "0") continue;
match.Groups.TryGetValue(group, out var value);
if (string.IsNullOrEmpty(value?.Value)) continue;
switch (group)
{
case "1":
FileName = value.Value;
break;
case "2":
Comment = value.Value;
break;
}
}
}
}
}