Indexnumber parsing disabled

This commit is contained in:
Simon Martens
2023-09-16 15:43:11 +02:00
parent f054c8913d
commit d86d508786
58 changed files with 447 additions and 297 deletions

View File

@@ -16,7 +16,7 @@ namespace HaDocument.Comparers
else if (first.Order != second.Order)
return first.Order.CompareTo(second.Order);
else
return String.Compare(first.Index, second.Index);
return String.Compare(first.ID, second.ID);
}
}
}

View File

@@ -13,8 +13,8 @@ namespace HaDocument.Comparers
{
var firstNumber = 0;
var secondNumber = 0;
Int32.TryParse(first.Index, out firstNumber);
Int32.TryParse(second.Index, out secondNumber);
Int32.TryParse(first.ID, out firstNumber);
Int32.TryParse(second.ID, out secondNumber);
return firstNumber.CompareTo(secondNumber);
//var firstIndex = from c in first.Meta.Autopsic

View File

@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.002.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HaDocumentV6", "HaDocumentV6.csproj", "{2D3B1B5C-5E0B-4050-A102-E44F025511BE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2D3B1B5C-5E0B-4050-A102-E44F025511BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2D3B1B5C-5E0B-4050-A102-E44F025511BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2D3B1B5C-5E0B-4050-A102-E44F025511BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2D3B1B5C-5E0B-4050-A102-E44F025511BE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E81F4186-AD0D-41A1-BA1B-93C1C7FEE7C7}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,5 @@
using System.Xml.Linq;
public interface IHaElement {
}

View File

@@ -11,7 +11,7 @@ namespace HaDocument.Interfaces {
ImmutableDictionary<string, Person> Persons { get; }
ImmutableDictionary<string, Meta> Metas { get; }
ImmutableDictionary<string, Meta> ExcludedMetas { get; }
ImmutableDictionary<string, Marginal> Marginals { get; }
ImmutableDictionary<string, List<Marginal>> Marginals { get; }
ImmutableDictionary<string, Location> Locations { get; }
ImmutableDictionary<string, Letter> Letters { get; }
ImmutableDictionary<string, Person> HandPersons { get; }
@@ -24,7 +24,6 @@ namespace HaDocument.Interfaces {
ImmutableDictionary<string, Lookup<string, Comment>> CommentsByCategoryLetter { get; }
Lookup<string, Comment> CommentsByCategory { get; }
Lookup<string, Marginal> MarginalsByLetter { get; }
Lookup<string, Editreason> EditreasonsByLetter { get; }
ImmutableSortedSet<Meta> MetasByDate { get; }
ILookup<int, Meta> MetasByYear { get; }

View File

@@ -1,6 +0,0 @@
namespace HaDocument.Interfaces;
public interface ISearchable {
public string Element { get; }
public string Index { get; }
}

View File

@@ -1,17 +1,34 @@
using System.Xml.Linq;
namespace HaDocument.Models {
public class App {
public string Index { get; } = "";
public string Name { get; } = "";
public string Category { get; } = "";
public XElement? XElement { get; }
public App(
string index,
string name,
string category
string category,
XElement? xElement = null
) {
Index = index;
Name = name;
Category = category;
XElement = xElement;
}
public static App? FromXElement(XElement element) {
if (!element.HasAttributes || element.Name != "appDef") return null;
if (element.Attribute("index")?.Value == null || element.Attribute("name")?.Value == null || element.Attribute("category")?.Value == null) return null;
return new App(
element.Attribute("index")!.Value,
element.Attribute("name")!.Value,
element.Attribute("category")!.Value,
element
);
}
}
}

View File

@@ -1,24 +1,68 @@
using System.Xml.Linq;
namespace HaDocument.Models {
public class Backlink {
public string Index { get; } = "";
public string Href { get; } = "";
public string Letter { get; } = "";
public string Page { get; } = "";
public string Line { get; } = "";
public string MarginalIndex { get; } = "";
public string? Letter { get; } = "";
public string? Page { get; } = "";
public string? Line { get; } = "";
public string? Comment { get; }
public Backlink(
string index,
string letter,
string page,
string line,
string marginalindex
string href,
string? letter,
string? page,
string? line,
string? comment = null
) {
Index = index;
Href = href;
Letter = letter;
Page = page;
Line = line;
MarginalIndex = marginalindex;
Comment = comment;
}
public static Backlink? FromXElement(XElement element) {
if (!element.HasAttributes || element.Name != "link") return null;
if (element.Attribute("ref")?.Value == null && element.Attribute("subref")?.Value == null) return null;
if (element.Ancestors("marginal") == null || !element.Ancestors("marginal").Any()) {
var marginal = element.Ancestors("marginal").First();
if (Marginal.FromXElement(marginal) == null) return null;
return new Backlink(
element.Attribute("subref")?.Value ?? element.Attribute("ref")!.Value,
marginal.Attribute("letter")!.Value,
marginal.Attribute("page")!.Value,
marginal.Attribute("line")!.Value
);
}
if (element.Ancestors("subsection") != null || !element.Ancestors("subsection").Any()) {
var subsection = element.Ancestors("subsection").First();
if (subsection.Attribute("id")?.Value == null) return null;
return new Backlink(
element.Attribute("subref")?.Value ?? element.Attribute("ref")!.Value,
null,
null,
null,
subsection.Attribute("id")!.Value
);
}
if (element.Ancestors("kommentar") != null || !element.Ancestors("kommentar").Any()) {
var kommentar = element.Ancestors("kommentar").First();
if (kommentar.Attribute("id")?.Value == null) return null;
return new Backlink(
element.Attribute("subref")?.Value ?? element.Attribute("ref")!.Value,
null,
null,
null,
kommentar.Attribute("id")!.Value
);
}
return null;
}
}
}

View File

@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Collections.Immutable;
namespace HaDocument.Models{
public class Comment : HaDocument.Interfaces.ISearchable {
public class Comment {
public string Element { get; } = "";
public string Index { get; } = "";
public string Type { get; } = "";

View File

@@ -1,5 +1,7 @@
using System.Xml.Linq;
namespace HaDocument.Models {
public class Editreason : HaDocument.Interfaces.ISearchable {
public class Editreason {
public string Index { get; } = "";
public string Element { get; } = "";
public string Letter { get; } = "";
@@ -28,5 +30,9 @@ namespace HaDocument.Models {
EndLine = endline;
Reference = reference;
}
public static Editreason? FromXElement(XElement element) {
throw new NotImplementedException("We need two Elements for editreason");
}
}
}

View File

@@ -1,15 +0,0 @@
using System;
using HaXMLReader.EvArgs;
using System.Collections.Generic;
namespace HaDocument.Models {
public abstract class HaModel {
protected static List<(Func<Tag, bool>, Action<Tag>)> FieldActions = null;
internal static void AddAction(Func<Tag, bool> If, Action<Tag> Then) {
if (If == null || Then == null) throw new ArgumentNullException();
if (FieldActions == null) FieldActions = new List<(Func<Tag, bool>, Action<Tag>)>();
FieldActions.Add((If, Then));
}
}
}

View File

@@ -1,5 +1,5 @@
namespace HaDocument.Models {
public class Hand : HaModel {
public class Hand {
public string Letter { get; } = "";
public string Person { get; } = "";
public string StartPage { get; } = "";

View File

@@ -9,7 +9,7 @@ namespace HaDocument.Models
public Dictionary<string, Person> Persons;
public Dictionary<string, Meta> Metas;
public Dictionary<string, Meta> ExcludedMetas;
public Dictionary<string, Marginal> Marginals;
public Dictionary<string, List<Marginal>> Marginals;
public Dictionary<string, Location> Locations;
public Dictionary<string, Letter> Letters;
public Dictionary<string, Person> HandPersons;

View File

@@ -1,14 +1,29 @@
using System.Xml.Linq;
namespace HaDocument.Models {
public class Letter : HaModel, HaDocument.Interfaces.ISearchable {
public string Index { get; } = "";
public class Letter {
public string ID { get; } = "";
public string Element { get; } = "";
public XElement? XElement { get; }
public Letter(
string index,
string element
string id,
string element,
XElement? xelement = null
) {
Index = index;
ID = id;
Element = element;
XElement = xelement;
}
public static Letter? FromXElement(XElement element) {
if (!element.HasAttributes || element.IsEmpty || element.Name != "letterText") return null;
if (element.Attribute("letter")?.Value == null) return null;
return new Letter(
element.Attribute("letter")!.Value,
element.ToString(),
element
);
}
}
}

View File

@@ -15,7 +15,7 @@ namespace HaDocument.Models
public ImmutableDictionary<string, Person> Persons { get; }
public ImmutableDictionary<string, Meta> Metas { get; }
public ImmutableDictionary<string, Meta> ExcludedMetas { get; }
public ImmutableDictionary<string, Marginal> Marginals { get; }
public ImmutableDictionary<string, List<Marginal>> Marginals { get; }
public ImmutableDictionary<string, Location> Locations { get; }
public ImmutableDictionary<string, Letter> Letters { get; }
public ImmutableDictionary<string, Person> HandPersons { get; }
@@ -35,8 +35,6 @@ namespace HaDocument.Models
public Lookup<string, Comment> CommentsByCategory { get; }
// Auswählen von Subkommentaren nach ID
public ImmutableDictionary<string, Comment> SubCommentsByID { get; }
// Auswählen von Marginalien nach Briefen
public Lookup<string, Marginal> MarginalsByLetter { get; }
// Ausw?hlen von Edits nach Briefen
public Lookup<string, Editreason> EditreasonsByLetter { get; }
// Auswählen von Briefen nach autoptischer Numemr und in zeitlich sortierter Reihenfolge.
@@ -51,7 +49,7 @@ namespace HaDocument.Models
Dictionary<string, Person> persons,
Dictionary<string, Meta> meta,
Dictionary<string, Meta> excludedMeta,
Dictionary<string, Marginal> marginals,
Dictionary<string, List<Marginal>> marginals,
Dictionary<string, Location> locations,
Dictionary<string, Letter> letters,
Dictionary<string, Person> handPersons,
@@ -95,7 +93,6 @@ namespace HaDocument.Models
CommentsByLetter_builder.Add(ts.Key, (Lookup<string, Comment>)ts.ToLookup(x => x.Index.Substring(0, 1).ToUpper()));
}
CommentsByCategoryLetter = CommentsByLetter_builder.ToImmutableDictionary();
MarginalsByLetter = (Lookup<string, Marginal>)Marginals.Values.ToLookup(x => x.Letter);
EditreasonsByLetter = (Lookup<string, Editreason>)Editreasons.Values.ToLookup(x => x.Letter);
MetasByDate = Metas.Values.ToImmutableSortedSet<Meta>(new DefaultComparer());
MetasByYear = Metas.Values.ToLookup(x => x.Sort.Year);

View File

@@ -1,14 +1,33 @@
using System.Xml.Linq;
namespace HaDocument.Models {
public class Location {
public string Index { get; } = "";
public string Name { get; } = "";
public string? Reference { get; }
public XElement? XElement { get; }
public Location(
string index,
string name
string name,
string? reference,
XElement? xelement = null
) {
Index = index;
Name = name;
XElement = xelement;
Reference = reference;
}
public static Location? FromXElement(XElement element) {
if (!element.HasAttributes || element.Name != "locationDef") return null;
if (element.Attribute("index")?.Value == null || element.Attribute("name")?.Value == null) return null;
return new Location(
element.Attribute("index")!.Value,
element.Attribute("name")!.Value,
element.Attribute("ref")?.Value,
element
);
}
}
}

View File

@@ -1,23 +1,41 @@
using System.Xml.Linq;
namespace HaDocument.Models {
public class Marginal : HaDocument.Interfaces.ISearchable {
public string Index { get; } = "";
public class Marginal {
public string? Sort { get; } = "";
public string Letter { get; } = "";
public string Page { get; } = "";
public string Line { get; } = "";
public string Element { get; } = "";
public XElement? XElement { get; }
public Marginal(
string index,
string letter,
string page,
string line,
string element
string? sort,
string element,
XElement? xelement = null
) {
Index = index;
Letter = letter;
Page = page;
Line = line;
Sort = sort;
Element = element;
XElement = xelement;
}
public static Marginal? FromXElement(XElement element) {
if (!element.HasAttributes || element.Name != "marginal" || element.IsEmpty) return null;
if (element.Attribute("letter")?.Value == null || element.Attribute("page")?.Value == null || element.Attribute("line")?.Value == null) return null;
return new Marginal(
element.Attribute("letter")!.Value,
element.Attribute("page")!.Value,
element.Attribute("line")!.Value,
element.Attribute("sort")?.Value,
element.ToString(),
element
);
}
}
}

View File

@@ -4,35 +4,32 @@ using HaXMLReader.EvArgs;
namespace HaDocument.Models {
public class Meta {
public string Index { get; } = "";
public string Autopsic { get; } = "";
public string ID { get; } = "";
public string Date { get; } = "";
public DateTime Sort { get; } = new DateTime(1700, 1, 1);
public int Order { get; } = -1;
public string Location { get; } = "";
public List<string> Senders { get; } = null;
public List<string> Receivers { get; } = null;
public OptionalBool hasOriginal { get; } = OptionalBool.None;
public OptionalBool isProofread { get; } = OptionalBool.None;
public OptionalBool isDraft { get; } = OptionalBool.None;
public bool? hasOriginal { get; }
public bool? isProofread { get; }
public bool? isDraft { get; }
public ZHInfo ZH { get; } = null;
public Meta(
string index,
string autopsic,
string id,
string date,
DateTime sort,
int order,
OptionalBool hasOriginal,
OptionalBool isProofread,
OptionalBool isDraft,
bool? hasOriginal,
bool? isProofread,
bool? isDraft,
string location,
List<string> senders,
List<string> receivers,
ZHInfo ZH
) {
Index = index;
Autopsic = autopsic;
ID = id;
Date = date;
Sort = sort;
Order = order;

View File

@@ -1,13 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace HaDocument.Models
{
public enum OptionalBool
{
True,
False,
None
}
}

View File

@@ -1,23 +1,44 @@
using System.Xml.Linq;
namespace HaDocument.Models {
public class Person {
public string Index { get; } = "";
public string Name { get; } = "";
public string Prename { get; } = "";
public string Surname { get; } = "";
public string Index { get; } = string.Empty;
public string Name { get; } = string.Empty;
public string? Prename { get; }
public string? Surname { get; }
public string? Komm { get; }
public string? Reference { get; }
public XElement? XElement { get; }
public Person(
string index,
string name,
string prename,
string surname,
string? komm
string? prename,
string? surname,
string? komm,
string? reference,
XElement? xElement = null
) {
Index = index;
Name = name;
Prename = prename;
Surname = surname;
Komm = komm;
Reference = reference;
}
public static Person? FromXElement(XElement element) {
if (!element.HasAttributes || (element.Name != "personDef" && element.Name != "handDef")) return null;
if (element.Attribute("index")?.Value == null || element.Attribute("name")?.Value == null) return null;
return new Person(
element.Attribute("index")!.Value,
element.Attribute("name")!.Value,
element.Attribute("vorname")?.Value,
element.Attribute("nachname")?.Value,
element.Attribute("komm")?.Value,
element.Attribute("ref")?.Value,
element
);
}
}
}

View File

@@ -1,14 +1,30 @@
using System.Xml.Linq;
namespace HaDocument.Models {
public class Tradition : HaDocument.Interfaces.ISearchable {
public string Index { get; } = "";
public class Tradition {
public string ID { get; } = "";
public string Element { get; } = "";
public XElement? XElement { get; }
public Tradition(
string index,
string element
string id,
string element,
XElement? xelement = null
) {
Index = index;
ID = id;
Element = element;
XElement = xelement;
}
public static Tradition? FromXElement(XElement element) {
if (!element.HasAttributes || element.IsEmpty || element.Name != "letterTradition") return null;
if (element.Attribute("letter")?.Value == null) return null;
return new Tradition(
element.Attribute("letter")!.Value,
element.ToString(),
element
);
}
}
}

View File

@@ -70,14 +70,14 @@ namespace HaDocument.Reactors {
!tag.IsEmpty &&
tag.Name == "letterText"
) {
letter = tag["index"];
letter = tag["letter"];
}
else if (
!tag.EndTag &&
!tag.IsEmpty &&
tag.Name == "letterTradition"
) {
letter = tag["ref"];
letter = tag["letter"];
}
else if (
!tag.EndTag &&

View File

@@ -13,7 +13,6 @@ namespace HaDocument.Reactors {
// State
private string Index;
private string Name;
private string? Komm;
internal HandDefsReactor(IReader reader, IntermediateLibrary lib) : base(reader, lib) {
lib.HandPersons = new Dictionary<string, Person>();
@@ -39,7 +38,6 @@ namespace HaDocument.Reactors {
_active = true;
Index = tag["index"];
Name = tag["name"];
if (!String.IsNullOrWhiteSpace(tag["komm"])) Komm = tag["komm"];
Add();
_active = false;
}
@@ -51,7 +49,7 @@ namespace HaDocument.Reactors {
}
protected void Add() {
CreatedInstances.Add(Index, new Person(Index, Name, "", "", Komm));
CreatedInstances.Add(Index, new Person(Index, Name, null, null, null, null));
}
}
}

View File

@@ -16,7 +16,7 @@ namespace HaDocument.Reactors
internal Dictionary<string, Dictionary<string, HashSet<string>>> CreatedStructure;
// State
private string Index = "";
private string Letter = "";
private ElementStringBinder _element = null;
private bool _normalizeWhitespace = false;
@@ -49,12 +49,12 @@ namespace HaDocument.Reactors
!tag.EndTag &&
!tag.IsEmpty &&
tag.Name == "letterText" &&
!String.IsNullOrWhiteSpace(tag["index"])
!String.IsNullOrWhiteSpace(tag["letter"])
)
{
Activate(_reader, tag);
if (!CreatedStructure.ContainsKey(tag["index"]))
this.CreatedStructure.Add(tag["index"], new Dictionary<string, HashSet<string>>());
if (!CreatedStructure.ContainsKey(tag["letter"]))
this.CreatedStructure.Add(tag["letter"], new Dictionary<string, HashSet<string>>());
}
else if (
!tag.EndTag &&
@@ -64,9 +64,9 @@ namespace HaDocument.Reactors
)
{
_line = tag["index"];
if (!CreatedStructure[Index][_page].Contains(_line))
if (!CreatedStructure[Letter][_page].Contains(_line))
{
CreatedStructure[Index][_page].Add(_line);
CreatedStructure[Letter][_page].Add(_line);
}
}
else if (
@@ -77,8 +77,8 @@ namespace HaDocument.Reactors
)
{
_page = tag["index"];
if (!CreatedStructure[Index].ContainsKey(_page))
CreatedStructure[Index].Add(_page, new HashSet<string>());
if (!CreatedStructure[Letter].ContainsKey(_page))
CreatedStructure[Letter].Add(_page, new HashSet<string>());
}
else if (
_active &&
@@ -100,7 +100,7 @@ namespace HaDocument.Reactors
{
if (_hands == null)
_hands = new List<Hand>();
_hands.Add(new Hand(Index, _person, _handstartpg, _handstartln, _page, _line));
_hands.Add(new Hand(Letter, _person, _handstartpg, _handstartln, _page, _line));
}
}
@@ -110,7 +110,7 @@ namespace HaDocument.Reactors
{
_active = true;
_reader = reader;
Index = tag["index"];
Letter = tag["letter"];
_element = new ElementStringBinder(reader, tag, Add, _normalizeWhitespace);
}
}
@@ -119,23 +119,23 @@ namespace HaDocument.Reactors
{
if (String.IsNullOrWhiteSpace(text)) return;
var letter = new Letter(
Index,
Letter,
text
);
CreatedInstances.TryAdd(Index, letter);
CreatedInstances.TryAdd(Letter, letter);
if (_hands != null)
{
if (!CreatedHands.ContainsKey(Index))
CreatedHands.Add(Index, _hands);
if (!CreatedHands.ContainsKey(Letter))
CreatedHands.Add(Letter, _hands);
else
CreatedHands[Index].AddRange(_hands);
CreatedHands[Letter].AddRange(_hands);
}
Reset();
}
protected override void Reset()
{
Index = "";
Letter = "";
_active = false;
_element = null;
_hands = null;

View File

@@ -14,6 +14,7 @@ namespace HaDocument.Reactors {
// State
private string Index;
private string Name;
private string? Reference;
internal LocationDefsReactor(IReader reader, IntermediateLibrary lib) : base(reader, lib) {
lib.Locations = new Dictionary<string, Location>();
@@ -39,6 +40,7 @@ namespace HaDocument.Reactors {
_active = true;
Index = tag["index"];
Name = tag["name"];
Reference = String.IsNullOrWhiteSpace(tag["ref"]) ? null : tag["ref"];
Add();
_active = false;
}
@@ -47,10 +49,11 @@ namespace HaDocument.Reactors {
protected override void Reset() {
Index = "";
Name = "";
Reference = null;
}
protected void Add() {
CreatedInstances.Add(Index, new Location(Index, Name));
CreatedInstances.Add(Index, new Location(Index, Name, Reference));
}
}
}

View File

@@ -6,12 +6,12 @@ using System;
namespace HaDocument.Reactors {
class MarginalReactor : Reactor {
internal Dictionary<string, Marginal> CreatedInstances;
internal Dictionary<string, List<Marginal>> CreatedInstances;
internal Dictionary<string, List<Backlink>> CreatedBacklinks;
private bool _normalizeWhitespace = false;
// State
private string Index = "";
private string? Sort = "";
private string Letter = "";
private string Page = "";
private string Line = "";
@@ -20,8 +20,8 @@ namespace HaDocument.Reactors {
internal MarginalReactor(IReader reader, IntermediateLibrary lib, bool normalizeWhitespace) : base(reader, lib) {
_normalizeWhitespace = normalizeWhitespace;
lib.Marginals = new Dictionary<string, Marginal>();
lib.Backlinks = new Dictionary<string, List<Backlink>>();
lib.Marginals = new ();
lib.Backlinks = new ();
CreatedBacklinks = lib.Backlinks;
CreatedInstances = lib.Marginals;
reader.OpenTag += Listen;
@@ -32,7 +32,6 @@ namespace HaDocument.Reactors {
!tag.EndTag &&
!tag.IsEmpty &&
tag.Name == "marginal" &&
!String.IsNullOrEmpty(tag["index"]) &&
!String.IsNullOrWhiteSpace(tag["letter"]) &&
!String.IsNullOrWhiteSpace(tag["page"]) &&
!String.IsNullOrWhiteSpace(tag["line"])
@@ -45,7 +44,7 @@ namespace HaDocument.Reactors {
if (!_active && reader != null && tag != null) {
_active = true;
_reader = reader;
Index = tag["index"];
Sort = tag["sort"];
Letter = tag["letter"];
Page = tag["page"];
Line = tag["line"];
@@ -67,7 +66,7 @@ namespace HaDocument.Reactors {
if (!String.IsNullOrWhiteSpace(id)) {
if (!CreatedBacklinks.ContainsKey(id))
CreatedBacklinks.Add(id, new List<Backlink>());
CreatedBacklinks[id].Add(new Backlink(id, Letter, Page, Line, Index));
CreatedBacklinks[id].Add(new Backlink(id, Letter, Page, Line));
}
}
}
@@ -75,18 +74,19 @@ namespace HaDocument.Reactors {
private void Add(string element) {
if (String.IsNullOrWhiteSpace(element)) return;
var marg = new Marginal(
Index,
Letter,
Page,
Line,
String.IsNullOrWhiteSpace(Sort) ? null : Sort,
element
);
CreatedInstances.TryAdd(Index, marg);
if (!CreatedInstances.ContainsKey(Letter)) CreatedInstances.Add(Letter, new());
CreatedInstances[Letter].Add(marg);
Reset();
}
protected override void Reset() {
Index = "";
Sort = "";
_active = false;
_element = null;
_reader.Tag -= OnTag;

View File

@@ -14,8 +14,7 @@ namespace HaDocument.Reactors {
private (int, int) _availableYearRange;
// State
private string Index { get; set; } = "";
private string Autopsic { get; set; } = "";
private string ID { get; set; } = "";
private string Volume { get; set; } = "";
private string Page { get; set; } = "";
private string Date { get; set; } = "";
@@ -23,9 +22,9 @@ namespace HaDocument.Reactors {
private int Order { get; set; } = -1;
private bool AltLineNumbering { get; set; } = false;
private bool inZH { get; set; } = false;
private OptionalBool hasOriginal { get; set; } = OptionalBool.None;
private OptionalBool isProofread { get; set; } = OptionalBool.None;
private OptionalBool isDraft { get; set; } = OptionalBool.None;
private bool? hasOriginal { get; set; } = null;
private bool? isProofread { get; set; } = null;
private bool? isDraft { get; set; } = null;
private bool dateChanged {get; set; } = false;
private string Location { get; set; } = "";
private List<string> Senders { get; set; } = null;
@@ -46,7 +45,7 @@ namespace HaDocument.Reactors {
!tag.EndTag &&
!tag.IsEmpty &&
tag.Name =="letterDesc" &&
!String.IsNullOrWhiteSpace(tag["ref"])
!String.IsNullOrWhiteSpace(tag["letter"])
) {
Activate(_reader, tag);
}
@@ -56,7 +55,7 @@ namespace HaDocument.Reactors {
if (!_active && reader != null && tag != null) {
Reset();
_active = true;
Index = tag["ref"];
ID = tag["letter"];
reader.Tag += OnTag;
_reader = reader;
}
@@ -79,10 +78,6 @@ namespace HaDocument.Reactors {
private void OnTag(object _, Tag tag) {
switch (tag.Name)
{
case "autopsic":
Autopsic = tag["value"];
if (String.IsNullOrWhiteSpace(Autopsic)) Abort();
break;
case "begin":
Page = tag["page"];
Volume = tag["vol"];
@@ -110,29 +105,29 @@ namespace HaDocument.Reactors {
case "hasOriginal":
var val = tag["value"];
if (val.ToLower() == "true")
hasOriginal = OptionalBool.True;
hasOriginal = true;
else if (val.ToLower() == "false")
hasOriginal = OptionalBool.False;
hasOriginal = false;
else
hasOriginal = OptionalBool.None;
hasOriginal = null;
break;
case "isProofread":
var val2 = tag["value"];
if (val2.ToLower() == "true")
isProofread = OptionalBool.True;
isProofread = true;
else if (val2.ToLower() == "false")
isProofread = OptionalBool.False;
isProofread = false;
else
isProofread = OptionalBool.None;
isProofread = null;
break;
case "isDraft":
var val3 = tag["value"];
if (val3.ToLower() == "true")
isDraft = OptionalBool.True;
isDraft = true;
else if (val3.ToLower() == "false")
isDraft = OptionalBool.False;
isDraft = false;
else
isDraft = OptionalBool.None;
isDraft = null;
break;
case "ZHInfo":
if (!tag.EndTag) {
@@ -154,8 +149,7 @@ namespace HaDocument.Reactors {
private void Add() {
var ZHInfo = !inZH ? null : new ZHInfo(AltLineNumbering, dateChanged, Volume, Page);
var meta = new Meta(
Index,
Autopsic,
ID,
Date,
Sort,
Order,
@@ -172,21 +166,20 @@ namespace HaDocument.Reactors {
(Sort.Year >= _availableYearRange.Item1 && Sort.Year <= _availableYearRange.Item2) ||
(_availableVolumes == null && _availableYearRange.Item1 == 0 && _availableYearRange.Item2 == 0)
) {
CreatedInstances.TryAdd(meta.Index, meta);
CreatedInstances.TryAdd(meta.ID, meta);
}
else {
ExcludedInstances.TryAdd(meta.Index, meta);
ExcludedInstances.TryAdd(meta.ID, meta);
}
}
protected override void Reset() {
inZH = true;
hasOriginal = OptionalBool.None;
isProofread = OptionalBool.None;
isDraft = OptionalBool.None;
hasOriginal = null;
isProofread = null;
isDraft = null;
dateChanged = false;
Index = "";
Autopsic = "";
ID = "";
Volume = "";
Page = "";
Date = "";

View File

@@ -15,6 +15,7 @@ namespace HaDocument.Reactors {
private string Name;
private string Prename = "";
private string Surname = "";
private string? Reference;
private string? Komm;
internal PersonDefsReactor(IReader reader, IntermediateLibrary lib) : base(reader, lib) {
@@ -42,6 +43,7 @@ namespace HaDocument.Reactors {
Name = tag["name"];
Prename = tag["vorname"];
Surname = tag["nachname"];
Reference = String.IsNullOrWhiteSpace(tag["ref"]) ? null : tag["ref"];
if (!String.IsNullOrWhiteSpace(tag["komm"])) Komm = tag["komm"];
Add();
_active = false;
@@ -53,11 +55,12 @@ namespace HaDocument.Reactors {
Name = "";
Prename = "";
Surname = "";
Reference = null;
Komm = null;
}
public void Add() {
CreatedInstances.Add(Index, new Person(Index, Name, Prename, Surname, Komm));
CreatedInstances.Add(Index, new Person(Index, Name, Prename, Surname, Komm, Reference));
}
}
}

View File

@@ -14,7 +14,7 @@ namespace HaDocument.Reactors
private bool _normalizeWhitespace = false;
// State
private string Index = "";
private string ID = "";
private string _page = "";
private string _line = "";
@@ -46,7 +46,7 @@ namespace HaDocument.Reactors
if (!tag.EndTag &&
!tag.IsEmpty &&
tag.Name == "letterTradition" &&
!String.IsNullOrWhiteSpace(tag["ref"])
!String.IsNullOrWhiteSpace(tag["letter"])
)
{
Activate(_reader, tag);
@@ -57,33 +57,33 @@ namespace HaDocument.Reactors
tag.Name == "ZHText"
)
{
if (!CreatedStructure.ContainsKey(tag["index"]))
this.CreatedStructure.Add(tag["index"], new Dictionary<string, HashSet<string>>());
if (!CreatedStructure.ContainsKey(tag["letter"]))
this.CreatedStructure.Add(tag["letter"], new Dictionary<string, HashSet<string>>());
}
else if (
!tag.EndTag &&
_active &&
tag.Name == "line" &&
!String.IsNullOrWhiteSpace(tag["index"])
!String.IsNullOrWhiteSpace(tag["letter"])
)
{
_line = tag["index"];
if (!CreatedStructure[Index][_page].Contains(_line))
_line = tag["letter"];
if (!CreatedStructure[ID][_page].Contains(_line))
{
CreatedStructure[Index][_page].Add(_line);
CreatedStructure[ID][_page].Add(_line);
}
}
else if (
!tag.EndTag &&
_active &&
tag.Name == "page" &&
!String.IsNullOrWhiteSpace(tag["index"])
!String.IsNullOrWhiteSpace(tag["letter"])
)
{
_page = tag["index"];
if (!CreatedStructure[Index].ContainsKey(_page))
_page = tag["letter"];
if (!CreatedStructure[ID].ContainsKey(_page))
{
CreatedStructure[Index].Add(_page, new HashSet<string>());
CreatedStructure[ID].Add(_page, new HashSet<string>());
}
}
else if (
@@ -106,7 +106,7 @@ namespace HaDocument.Reactors
{
if (_hands == null)
_hands = new List<Hand>();
_hands.Add(new Hand(Index, _person, _handstartpg, _handstartln, _page, _line));
_hands.Add(new Hand(ID, _person, _handstartpg, _handstartln, _page, _line));
}
}
@@ -115,7 +115,7 @@ namespace HaDocument.Reactors
if (!_active && reader != null && tag != null)
{
_active = true;
Index = tag["ref"];
ID = tag["letter"];
_element = new ElementStringBinder(reader, tag, Add, _normalizeWhitespace);
}
}
@@ -124,22 +124,22 @@ namespace HaDocument.Reactors
{
if (String.IsNullOrWhiteSpace(element)) return;
var reason = new Tradition(
Index,
ID,
element);
CreatedInstances.TryAdd(Index, reason);
CreatedInstances.TryAdd(ID, reason);
if (_hands != null)
{
if (!CreatedHands.ContainsKey(Index))
CreatedHands.Add(Index, _hands);
if (!CreatedHands.ContainsKey(ID))
CreatedHands.Add(ID, _hands);
else
CreatedHands[Index].AddRange(_hands);
CreatedHands[ID].AddRange(_hands);
}
Reset();
}
protected override void Reset()
{
Index = "";
ID = "";
_page = "";
_line = "";
_active = false;