source code checkin

This commit is contained in:
Brett Hewitson 2021-01-07 16:23:23 +10:00
parent 5f8fb2c825
commit 7e57b72e35
675 changed files with 168433 additions and 0 deletions

View file

@ -0,0 +1,69 @@
using ServerManagerTool.Common.Interfaces;
using System;
using System.Linq;
namespace ServerManagerTool.Common.Model
{
public class CustomList : SortableObservableCollection<CustomSection>, IIniSectionCollection
{
public IIniValuesCollection[] Sections
{
get
{
return this.ToArray();
}
}
public void Add(string sectionName, string[] values)
{
Add(sectionName, values, true);
}
public void Add(string sectionName, string[] values, bool clearExisting)
{
var section = this.Items.FirstOrDefault(s => s.SectionName.Equals(sectionName, StringComparison.OrdinalIgnoreCase) && !s.IsDeleted);
if (section == null)
{
section = new CustomSection();
section.SectionName = sectionName;
this.Add(section);
}
if (clearExisting)
section.Clear();
section.FromIniValues(values);
}
public new void Clear()
{
foreach (var section in this)
{
section.IsDeleted = true;
}
Update();
}
public new void Remove(CustomSection item)
{
if (item != null)
item.IsDeleted = true;
Update();
}
public override string ToString()
{
return $"Count={Count}";
}
public void Update()
{
foreach (var section in this)
{
section.Update();
}
this.Sort(s => s.SectionName);
}
}
}