mirror of
https://github.com/Theodor-Springmann-Stiftung/hamann-ausgabe-core.git
synced 2025-10-29 17:25:32 +00:00
Added support for AppDefs; Updated currend XML
This commit is contained in:
@@ -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; }
|
||||
|
||||
16
HaDocumentV6/Models/App.cs
Normal file
16
HaDocumentV6/Models/App.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
60
HaDocumentV6/Reactors/AppDefsReactor.cs
Normal file
60
HaDocumentV6/Reactors/AppDefsReactor.cs
Normal 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user