mirror of
https://github.com/Theodor-Springmann-Stiftung/hamann-ausgabe-core.git
synced 2025-10-30 01:35:32 +00:00
Seperation of concerns: Seperated used File Management form Overall FIle Management
This commit is contained in:
25
HaWeb/Models/FileList.cs
Normal file
25
HaWeb/Models/FileList.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
namespace HaWeb.Models;
|
||||
using HaWeb.XMLParser;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
public class FileList {
|
||||
private HashSet<XMLRootDocument>? _Files;
|
||||
|
||||
[JsonIgnore]
|
||||
public IXMLRoot XMLRoot { get; private set; }
|
||||
|
||||
public FileList(IXMLRoot xmlRoot) {
|
||||
XMLRoot = xmlRoot;
|
||||
}
|
||||
|
||||
public void Add(XMLRootDocument document) {
|
||||
if (document.Prefix != XMLRoot.Prefix)
|
||||
throw new Exception("Diese Liste kann nur Elemente des Typs " + XMLRoot.Prefix + " enthalten");
|
||||
|
||||
if (_Files == null) _Files = new HashSet<XMLRootDocument>();
|
||||
if (!_Files.Contains(document)) _Files.Add(document);
|
||||
}
|
||||
|
||||
public List<XMLRootDocument>? GetFileList()
|
||||
=> this._Files != null ? this._Files.ToList() : null;
|
||||
}
|
||||
Reference in New Issue
Block a user