mirror of
https://github.com/Theodor-Springmann-Stiftung/hamann-ausgabe-core.git
synced 2025-10-30 01:35:32 +00:00
Added collection classes. Will not do extra collection for subcomments rn.
This commit is contained in:
@@ -3,45 +3,40 @@ using HaWeb.XMLParser;
|
||||
|
||||
public class ItemsCollection {
|
||||
public string Name { get; private set; }
|
||||
public Dictionary<string, CollectedItem> Items { get; private set; }
|
||||
public bool Searchable { get; private set; }
|
||||
public IXMLRoot Root { get; private set; }
|
||||
public Func<List<CollectedItem>, Dictionary<string, Lookup<string, CollectedItem>>?>? GroupingsGeneration { get; private set; }
|
||||
public Func<List<CollectedItem>, Dictionary<string, List<CollectedItem>>?>? SortingsGeneration { get; private set; }
|
||||
public IDictionary<string, CollectedItem> Items { get; private set; }
|
||||
public IXMLCollection Collection { get; private set; }
|
||||
|
||||
public Dictionary<string, Lookup<string, CollectedItem>>? Groupings { get; private set; }
|
||||
public Dictionary<string, List<CollectedItem>>? Sortings { get; private set; }
|
||||
public IDictionary<string, ILookup<string, CollectedItem>>? Groupings { get; private set; }
|
||||
public IDictionary<string, IEnumerable<CollectedItem>>? Sortings { get; private set; }
|
||||
|
||||
public ItemsCollection(
|
||||
string name,
|
||||
bool searchable,
|
||||
IXMLRoot root,
|
||||
Func<List<CollectedItem>, Dictionary<string, Lookup<string, CollectedItem>>?>? groupingsFunc = null,
|
||||
Func<List<CollectedItem>, Dictionary<string, List<CollectedItem>>?>? sortingsFunc = null
|
||||
IXMLCollection collection
|
||||
) {
|
||||
this.Name = name;
|
||||
this.Searchable = searchable;
|
||||
this.Root = root;
|
||||
this.GroupingsGeneration = groupingsFunc;
|
||||
this.SortingsGeneration = sortingsFunc;
|
||||
this.Collection = collection;
|
||||
this.Items = new Dictionary<string, CollectedItem>();
|
||||
}
|
||||
|
||||
public void GenerateGroupings(
|
||||
Func<List<CollectedItem>, Dictionary<string, Lookup<string, CollectedItem>>?>? groupingsFunc = null
|
||||
Func<IEnumerable<CollectedItem>, Dictionary<string, ILookup<string, CollectedItem>>?>? groupingsFunc = null
|
||||
) {
|
||||
if (groupingsFunc != null)
|
||||
this.GroupingsGeneration = groupingsFunc;
|
||||
if (this.GroupingsGeneration != null && this.Items.Any())
|
||||
this.Groupings = GroupingsGeneration(this.Items.Values.ToList());
|
||||
if (groupingsFunc != null) {
|
||||
this.Groupings = groupingsFunc(this.Items.Values.ToList());
|
||||
return;
|
||||
}
|
||||
if (Collection.GroupingsGeneration != null && this.Items.Any())
|
||||
this.Groupings = Collection.GroupingsGeneration(this.Items.Values.ToList());
|
||||
}
|
||||
|
||||
public void GenerateSortings(
|
||||
Func<List<CollectedItem>, Dictionary<string, List<CollectedItem>>?>? sortingsFunc = null
|
||||
Func<IEnumerable<CollectedItem>, Dictionary<string, IEnumerable<CollectedItem>>?>? sortingsFunc = null
|
||||
) {
|
||||
if (sortingsFunc != null)
|
||||
this.SortingsGeneration = sortingsFunc;
|
||||
if (this.SortingsGeneration != null && this.Items.Any())
|
||||
this.Sortings = SortingsGeneration(this.Items.Values.ToList());
|
||||
if (sortingsFunc != null) {
|
||||
this.Sortings = sortingsFunc(this.Items.Values.ToList());
|
||||
return;
|
||||
}
|
||||
if (Collection.SortingsGeneration != null && this.Items.Any())
|
||||
this.Sortings = Collection.SortingsGeneration(this.Items.Values.ToList());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user