Fixes in Scales
This commit is contained in:
@ -12,8 +12,8 @@ namespace Elwig.Helpers {
|
||||
public string DatabaseFile = App.DataPath + "database.sqlite3";
|
||||
public string? DatabaseLog = null;
|
||||
public string? Branch = null;
|
||||
public IEnumerable<string[]> Scales;
|
||||
private readonly LinkedList<string[]> ScaleList = new();
|
||||
public IList<string?[]> Scales;
|
||||
private readonly List<string?[]> ScaleList = new();
|
||||
|
||||
public Config(string filename) {
|
||||
FileName = filename;
|
||||
@ -54,9 +54,16 @@ namespace Elwig.Helpers {
|
||||
Scales = ScaleList;
|
||||
if (ini != null) {
|
||||
foreach (var s in ini.Sections.Where(s => s.SectionName.StartsWith("scale."))) {
|
||||
ScaleList.AddLast(new string[] {
|
||||
string? scaleLog = null;
|
||||
if (s.Keys["log"] != null) {
|
||||
scaleLog = s.Keys["log"];
|
||||
if (scaleLog.Length <= 1 || (scaleLog[1] != ':' && scaleLog[0] != '/' && scaleLog[0] != '\\')) {
|
||||
scaleLog = App.DataPath + scaleLog;
|
||||
}
|
||||
}
|
||||
ScaleList.Add(new string?[] {
|
||||
s.SectionName[6..], s.Keys["type"], s.Keys["model"], s.Keys["connection"],
|
||||
s.Keys["empty"], s.Keys["filling"], s.Keys["limit"]
|
||||
s.Keys["empty"], s.Keys["filling"], s.Keys["limit"], scaleLog
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -64,6 +71,8 @@ namespace Elwig.Helpers {
|
||||
|
||||
public void Write() {
|
||||
using var file = new StreamWriter(FileName, false, Encoding.UTF8);
|
||||
file.Write($"\r\n[general]\r\n");
|
||||
if (Branch != null) file.Write($"branch = {Branch}\r\n");
|
||||
file.Write($"\r\n[database]\r\nfile = {DatabaseFile}\r\n");
|
||||
if (DatabaseLog != null) file.Write($"log = {DatabaseLog}\r\n");
|
||||
foreach (var s in ScaleList) {
|
||||
@ -71,6 +80,7 @@ namespace Elwig.Helpers {
|
||||
if (s[4] != null) file.Write($"empty = {s[4]}\r\n");
|
||||
if (s[5] != null) file.Write($"filling = {s[5]}\r\n");
|
||||
if (s[6] != null) file.Write($"limit = {s[6]}\r\n");
|
||||
if (s[7] != null) file.Write($"log = {s[7]}\r\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user