Added support for AppDefs; Updated currend XML

This commit is contained in:
Simon Martens
2022-11-25 20:05:29 +01:00
parent 02abfb111a
commit ccfcadb91b
22 changed files with 526633 additions and 79611 deletions

View File

@@ -14,6 +14,7 @@ namespace HaDocument.Interfaces {
ImmutableDictionary<string, Location> Locations { get; }
ImmutableDictionary<string, Letter> Letters { get; }
ImmutableDictionary<string, Person> HandPersons { get; }
ImmutableDictionary<string, App> Apps { get; }
ImmutableDictionary<string, Editreason> Editreasons { get; }
ImmutableDictionary<string, Comment> Comments { get; }
ImmutableDictionary<string, ImmutableList<Backlink>> Backlinks { get; }

View File

@@ -0,0 +1,16 @@
namespace HaDocument.Models {
public class App {
public string Index { get; } = "";
public string Name { get; } = "";
public bool Category { get; } = false;
public App(
string index,
string name,
bool category
) {
Index = index;
Name = name;
}
}
}

View File

@@ -16,6 +16,7 @@ namespace HaDocument.Models
public Dictionary<string, Comment> Comments;
public Dictionary<string, List<Backlink>> Backlinks;
public Dictionary<string, List<Hand>> Hands;
public Dictionary<string, App> Apps;
// Helper Library for precalculationg the Structure of the Document:
public Dictionary<string, Dictionary<string, HashSet<string>>> LetterPageLines;
@@ -63,6 +64,7 @@ namespace HaDocument.Models
Backlinks,
Hands,
Structure,
Apps,
options
);
}

View File

@@ -18,6 +18,7 @@ namespace HaDocument.Models
public ImmutableDictionary<string, Location> Locations { get; }
public ImmutableDictionary<string, Letter> Letters { get; }
public ImmutableDictionary<string, Person> HandPersons { get; }
public ImmutableDictionary<string, App> Apps { get; }
public ImmutableDictionary<string, Editreason> Editreasons { get; }
public ImmutableDictionary<string, Comment> Comments { get; }
public ImmutableDictionary<string, ImmutableList<Backlink>> Backlinks { get; }
@@ -56,6 +57,7 @@ namespace HaDocument.Models
Dictionary<string, List<Backlink>> backlinks,
Dictionary<string, List<Hand>> hands,
Dictionary<string, Dictionary<string, Dictionary<string, string>>> Structure,
Dictionary<string, App> apps,
IHaDocumentOptions options
)
{
@@ -69,6 +71,7 @@ namespace HaDocument.Models
HandPersons = ImmutableDictionary.ToImmutableDictionary(handPersons);
Editreasons = ImmutableDictionary.ToImmutableDictionary(editReasons);
Comments = ImmutableDictionary.ToImmutableDictionary(comments);
Apps = ImmutableDictionary.ToImmutableDictionary(apps);
var backbuilder = ImmutableDictionary.CreateBuilder<string, ImmutableList<Backlink>>();
foreach (var entry in backlinks)

View File

@@ -0,0 +1,60 @@
using System;
using HaXMLReader.EvArgs;
using HaXMLReader.Interfaces;
using HaDocument.Models;
using System.Collections.Generic;
using System.Text;
using System.Xml;
namespace HaDocument.Reactors {
class AppDefsReactor : Reactor {
internal Dictionary<string, App> CreatedInstances;
// State
private string Index;
private string Name;
private bool Category;
internal AppDefsReactor(IReader reader, IntermediateLibrary lib) : base(reader, lib) {
lib.Locations = new Dictionary<string, Location>();
CreatedInstances = lib.Apps;
reader.Tag += Listen;
}
protected override void Listen(object sender, Tag tag) {
if (
!tag.EndTag &&
tag.IsEmpty &&
tag.Name == "appDef" &&
!String.IsNullOrWhiteSpace(tag["index"]) &&
!String.IsNullOrWhiteSpace(tag["name"])
) {
Activate(_reader, tag);
}
}
protected override void Activate(IReader reader, Tag tag) {
if (!_active && reader != null && tag != null) {
Reset();
_active = true;
Index = tag["index"];
Name = tag["name"];
if (!String.IsNullOrWhiteSpace(tag["category"] ))
Category = tag["category"] == "true" ? true : false;
Add();
_active = false;
}
}
protected override void Reset() {
Index = "";
Name = "";
Category = false;
}
protected void Add() {
CreatedInstances.Add(Index, new App(Index, Name, Category));
}
}
}