mirror of
https://github.com/Theodor-Springmann-Stiftung/hamann-ausgabe-core.git
synced 2025-10-29 09:15:33 +00:00
See last commit.
This commit is contained in:
@@ -7,14 +7,23 @@ public class CollectedItem : ISearchable {
|
||||
public string Index { get; private set; }
|
||||
public string Collection { get; private set; }
|
||||
public string? SearchText { get; private set; }
|
||||
public Dictionary<string, string[]>? Fields { get; private set; }
|
||||
public XElement ELement { get; private set; }
|
||||
public IXMLRoot Root { get; private set; }
|
||||
|
||||
public CollectedItem(string index, XElement element, IXMLRoot root, string collection, string? searchtext = null) {
|
||||
public CollectedItem(
|
||||
string index,
|
||||
XElement element,
|
||||
IXMLRoot root,
|
||||
string collection,
|
||||
Dictionary<string, string[]>? fields,
|
||||
string? searchtext = null
|
||||
) {
|
||||
this.Index = index;
|
||||
this.SearchText = searchtext;
|
||||
this.Collection = collection;
|
||||
this.Root = root;
|
||||
this.ELement = element;
|
||||
this.Fields = fields;
|
||||
}
|
||||
}
|
||||
47
HaWeb/Models/ItemsCollection.cs
Normal file
47
HaWeb/Models/ItemsCollection.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
namespace HaWeb.Models;
|
||||
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 Dictionary<string, Lookup<string, CollectedItem>>? Groupings { get; private set; }
|
||||
public Dictionary<string, List<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
|
||||
) {
|
||||
this.Name = name;
|
||||
this.Searchable = searchable;
|
||||
this.Root = root;
|
||||
this.GroupingsGeneration = groupingsFunc;
|
||||
this.SortingsGeneration = sortingsFunc;
|
||||
this.Items = new Dictionary<string, CollectedItem>();
|
||||
}
|
||||
|
||||
public void GenerateGroupings(
|
||||
Func<List<CollectedItem>, Dictionary<string, Lookup<string, CollectedItem>>?>? groupingsFunc = null
|
||||
) {
|
||||
if (groupingsFunc != null)
|
||||
this.GroupingsGeneration = groupingsFunc;
|
||||
if (this.GroupingsGeneration != null && this.Items.Any())
|
||||
this.Groupings = GroupingsGeneration(this.Items.Values.ToList());
|
||||
}
|
||||
|
||||
public void GenerateSortings(
|
||||
Func<List<CollectedItem>, Dictionary<string, List<CollectedItem>>?>? sortingsFunc = null
|
||||
) {
|
||||
if (sortingsFunc != null)
|
||||
this.SortingsGeneration = sortingsFunc;
|
||||
if (this.SortingsGeneration != null && this.Items.Any())
|
||||
this.Sortings = SortingsGeneration(this.Items.Values.ToList());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user