See last commit.

This commit is contained in:
schnulller
2022-06-25 23:01:52 +02:00
parent 65e18f136d
commit 056ab77888
14 changed files with 186 additions and 56 deletions

View File

@@ -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;
}
}

View 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());
}
}