mirror of
https://github.com/Theodor-Springmann-Stiftung/hamann-ausgabe-core.git
synced 2025-10-29 17:25:32 +00:00
Moved unused code into Achive
This commit is contained in:
454
Archive/HaDocument/.gitignore
vendored
Normal file
454
Archive/HaDocument/.gitignore
vendored
Normal file
@@ -0,0 +1,454 @@
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
##
|
||||
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||
|
||||
# User-specific files
|
||||
*.rsuser
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Mono auto generated files
|
||||
mono_crash.*
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
[Ww][Ii][Nn]32/
|
||||
[Aa][Rr][Mm]/
|
||||
[Aa][Rr][Mm]64/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Ll]og/
|
||||
[Ll]ogs/
|
||||
|
||||
# Visual Studio 2015/2017 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# Visual Studio 2017 auto generated files
|
||||
Generated\ Files/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NUnit
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
nunit-*.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# Benchmark Results
|
||||
BenchmarkDotNet.Artifacts/
|
||||
|
||||
# .NET
|
||||
project.lock.json
|
||||
project.fragment.lock.json
|
||||
artifacts/
|
||||
|
||||
# Tye
|
||||
.tye/
|
||||
|
||||
# ASP.NET Scaffolding
|
||||
ScaffoldingReadMe.txt
|
||||
|
||||
# StyleCop
|
||||
StyleCopReport.xml
|
||||
|
||||
# Files built by Visual Studio
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_h.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.iobj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.ipdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*_wpftmp.csproj
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
*.VC.db
|
||||
*.VC.VC.opendb
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# Visual Studio Trace Files
|
||||
*.e2e
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# AxoCover is a Code Coverage Tool
|
||||
.axoCover/*
|
||||
!.axoCover/settings.json
|
||||
|
||||
# Coverlet is a free, cross platform Code Coverage Tool
|
||||
coverage*.json
|
||||
coverage*.xml
|
||||
coverage*.info
|
||||
|
||||
# Visual Studio code coverage results
|
||||
*.coverage
|
||||
*.coveragexml
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
nCrunchTemp_*
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||
# in these scripts will be unencrypted
|
||||
PublishScripts/
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# NuGet Symbol Packages
|
||||
*.snupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/[Pp]ackages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/[Pp]ackages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/[Pp]ackages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignorable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
ecf/
|
||||
rcf/
|
||||
|
||||
# Windows Store app package directories and files
|
||||
AppPackages/
|
||||
BundleArtifacts/
|
||||
Package.StoreAssociation.xml
|
||||
_pkginfo.txt
|
||||
*.appx
|
||||
*.appxbundle
|
||||
*.appxupload
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!?*.[Cc]ache/
|
||||
|
||||
# Others
|
||||
ClientBin/
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.jfm
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
orleans.codegen.cs
|
||||
|
||||
# Including strong name files can present a security risk
|
||||
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||
#*.snk
|
||||
|
||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||
#bower_components/
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
ServiceFabricBackup/
|
||||
*.rptproj.bak
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
*.ndf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
*.rptproj.rsuser
|
||||
*- [Bb]ackup.rdl
|
||||
*- [Bb]ackup ([0-9]).rdl
|
||||
*- [Bb]ackup ([0-9][0-9]).rdl
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
node_modules/
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||
*.vbw
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/ModelManifest.xml
|
||||
**/*.Server/GeneratedArtifacts
|
||||
**/*.Server/ModelManifest.xml
|
||||
_Pvt_Extensions
|
||||
|
||||
# Paket dependency manager
|
||||
.paket/paket.exe
|
||||
paket-files/
|
||||
|
||||
# FAKE - F# Make
|
||||
.fake/
|
||||
|
||||
# CodeRush personal settings
|
||||
.cr/personal
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
# Cake - Uncomment if you are using it
|
||||
# tools/**
|
||||
# !tools/packages.config
|
||||
|
||||
# Tabs Studio
|
||||
*.tss
|
||||
|
||||
# Telerik's JustMock configuration file
|
||||
*.jmconfig
|
||||
|
||||
# BizTalk build output
|
||||
*.btp.cs
|
||||
*.btm.cs
|
||||
*.odx.cs
|
||||
*.xsd.cs
|
||||
|
||||
# OpenCover UI analysis results
|
||||
OpenCover/
|
||||
|
||||
# Azure Stream Analytics local run output
|
||||
ASALocalRun/
|
||||
|
||||
# MSBuild Binary and Structured Log
|
||||
*.binlog
|
||||
|
||||
# NVidia Nsight GPU debugger configuration file
|
||||
*.nvuser
|
||||
|
||||
# MFractors (Xamarin productivity tool) working folder
|
||||
.mfractor/
|
||||
|
||||
# Local History for Visual Studio
|
||||
.localhistory/
|
||||
|
||||
# BeatPulse healthcheck temp database
|
||||
healthchecksdb
|
||||
|
||||
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||
MigrationBackup/
|
||||
|
||||
# Ionide (cross platform F# VS Code tools) working folder
|
||||
.ionide/
|
||||
|
||||
# Fody - auto-generated XML schema
|
||||
FodyWeavers.xsd
|
||||
|
||||
##
|
||||
## Visual studio for Mac
|
||||
##
|
||||
|
||||
|
||||
# globs
|
||||
Makefile.in
|
||||
*.userprefs
|
||||
*.usertasks
|
||||
config.make
|
||||
config.status
|
||||
aclocal.m4
|
||||
install-sh
|
||||
autom4te.cache/
|
||||
*.tar.gz
|
||||
tarballs/
|
||||
test-results/
|
||||
|
||||
# Mac bundle stuff
|
||||
*.dmg
|
||||
*.app
|
||||
|
||||
# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore
|
||||
# General
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Icon must end with two \r
|
||||
Icon
|
||||
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear in the root of a volume
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
# content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore
|
||||
# Windows thumbnail cache files
|
||||
Thumbs.db
|
||||
ehthumbs.db
|
||||
ehthumbs_vista.db
|
||||
|
||||
# Dump file
|
||||
*.stackdump
|
||||
|
||||
# Folder config file
|
||||
[Dd]esktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Windows Installer files
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# Windows shortcuts
|
||||
*.lnk
|
||||
|
||||
# JetBrains Rider
|
||||
.idea/
|
||||
*.sln.iml
|
||||
|
||||
##
|
||||
## Visual Studio Code
|
||||
##
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
15
Archive/HaDocument/Comparers/CommentComparer.cs
Normal file
15
Archive/HaDocument/Comparers/CommentComparer.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using HaDocument.Models;
|
||||
|
||||
namespace HaDocument.Comparers {
|
||||
public class CommentComparer : IComparer<Comment> {
|
||||
public int Compare(Comment first, Comment second) {
|
||||
if (first.Order != second.Order)
|
||||
return first.Order.CompareTo(second.Order);
|
||||
else
|
||||
return first.Index.CompareTo(second.Index);
|
||||
}
|
||||
}
|
||||
}
|
||||
22
Archive/HaDocument/Comparers/DefaultComparer.cs
Normal file
22
Archive/HaDocument/Comparers/DefaultComparer.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using HaDocument.Models;
|
||||
|
||||
namespace HaDocument.Comparers
|
||||
{
|
||||
public class DefaultComparer : IComparer<Meta>
|
||||
{
|
||||
public int Compare(Meta first, Meta second)
|
||||
{
|
||||
if (first.Sort != second.Sort)
|
||||
return System.DateTime.Compare(first.Sort, second.Sort);
|
||||
else if (first.Order != second.Order)
|
||||
return first.Order.CompareTo(second.Order);
|
||||
else
|
||||
return String.Compare(first.Index, second.Index);
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Archive/HaDocument/Comparers/PersonComparer.cs
Normal file
13
Archive/HaDocument/Comparers/PersonComparer.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using HaDocument.Models;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace HaDocument.Comparers {
|
||||
public class PersonComparer : IComparer<Person> {
|
||||
public int Compare(Person first, Person second) {
|
||||
var cmp = String.Compare(first.Surname, second.Surname);
|
||||
if (cmp == 0) cmp = String.Compare(first.Name, second.Name);
|
||||
return cmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
41
Archive/HaDocument/Comparers/ZHComparer.cs
Normal file
41
Archive/HaDocument/Comparers/ZHComparer.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using HaDocument.Models;
|
||||
|
||||
namespace HaDocument.Comparers
|
||||
{
|
||||
public class ZHComparer : IComparer<Meta>
|
||||
{
|
||||
public int Compare(Meta first, Meta second)
|
||||
{
|
||||
var firstNumber = 0;
|
||||
var secondNumber = 0;
|
||||
Int32.TryParse(first.Index, out firstNumber);
|
||||
Int32.TryParse(second.Index, out secondNumber);
|
||||
return firstNumber.CompareTo(secondNumber);
|
||||
|
||||
//var firstIndex = from c in first.Meta.Autopsic
|
||||
// where char.IsDigit(c)
|
||||
// select c;
|
||||
//var secondIndex = from c in second.Meta.Autopsic
|
||||
// where char.IsDigit(c)
|
||||
// select c;
|
||||
//int firstNumber = 0;
|
||||
//int secondNumber = 0;
|
||||
//Int32.TryParse(String.Join("", firstIndex), out firstNumber);
|
||||
//Int32.TryParse(String.Join("", secondIndex), out secondNumber);
|
||||
//if (firstNumber.CompareTo(secondNumber) != 0)
|
||||
// return firstNumber.CompareTo(secondNumber);
|
||||
//var firstChar = from c in first.Meta.Autopsic
|
||||
// where char.IsMeta(c)
|
||||
// select c;
|
||||
//var secondChar = from c in first.Meta.Autopsic
|
||||
// where char.IsMeta(c)
|
||||
// select c;
|
||||
//return String.Compare(String.Join("", firstChar), String.Join("", secondChar));
|
||||
}
|
||||
}
|
||||
}
|
||||
55
Archive/HaDocument/Document.cs
Normal file
55
Archive/HaDocument/Document.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using HaDocument.Models;
|
||||
using HaDocument.Interfaces;
|
||||
using HaDocument.Logic;
|
||||
using HaDocument.Reactors;
|
||||
using HaXMLReader.Interfaces;
|
||||
using HaXMLReader;
|
||||
|
||||
namespace HaDocument
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides basic Access to the Letter.
|
||||
/// Initializes the parsing.
|
||||
/// Needs an Option Object as specified in IHaDocumentOptions.
|
||||
/// In case, the options change, the Object must be disposed and recreated.
|
||||
/// </summary>
|
||||
public static class Document
|
||||
{
|
||||
private static IHaDocumentOptions _settings;
|
||||
private static IReader _reader = null;
|
||||
private static IntermediateLibrary _lib = new IntermediateLibrary();
|
||||
private static ILibrary _library;
|
||||
|
||||
public static ILibrary Create(IHaDocumentOptions Settings) {
|
||||
SettingsValidator.Validate(Settings);
|
||||
_settings = Settings;
|
||||
_createReader();
|
||||
_createReactors();
|
||||
_reader.Read();
|
||||
_library = _createLibrary();
|
||||
return GetLibrary();
|
||||
}
|
||||
|
||||
private static void _createReactors() {
|
||||
new EditreasonReactor(_reader, _lib, _settings.NormalizeWhitespace);
|
||||
new HandDefsReactor(_reader, _lib);
|
||||
new LetterReactor(_reader, _lib, _settings.NormalizeWhitespace);
|
||||
new LocationDefsReactor(_reader, _lib);
|
||||
new MarginalReactor(_reader, _lib, _settings.NormalizeWhitespace);
|
||||
new MetaReactor(_reader, _lib, _settings.AvailableVolumes, _settings.AvailableYearRange);
|
||||
new PersonDefsReactor(_reader, _lib);
|
||||
new TraditionsReactor(_reader, _lib, _settings.NormalizeWhitespace);
|
||||
new CommentReactor(_reader, _lib, _settings.NormalizeWhitespace);
|
||||
}
|
||||
|
||||
private static void _createReader() {
|
||||
_reader = new FileReader(_settings.HamannXMLFilePath);
|
||||
}
|
||||
|
||||
private static ILibrary _createLibrary()
|
||||
=> _lib.GetLibrary(_settings);
|
||||
|
||||
public static ILibrary GetLibrary()
|
||||
=> _library;
|
||||
}
|
||||
}
|
||||
11
Archive/HaDocument/Exceptions/ObjectBotchedException.cs
Normal file
11
Archive/HaDocument/Exceptions/ObjectBotchedException.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System;
|
||||
|
||||
namespace HaDocument.Exceptions {
|
||||
public class ObjectBotchedException : Exception {
|
||||
public ObjectBotchedException() { }
|
||||
|
||||
public ObjectBotchedException(string msg) : base (msg) { }
|
||||
|
||||
public ObjectBotchedException(string msg, Exception inner) : base (msg, inner) { }
|
||||
}
|
||||
}
|
||||
10
Archive/HaDocument/Exceptions/ObjectNotFoundException.cs
Normal file
10
Archive/HaDocument/Exceptions/ObjectNotFoundException.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
namespace HaDocument.Exceptions {
|
||||
public class ObjectNotFoundException : Exception {
|
||||
public ObjectNotFoundException() { }
|
||||
|
||||
public ObjectNotFoundException(string msg) : base (msg) { }
|
||||
|
||||
public ObjectNotFoundException(string msg, Exception inner) : base (msg, inner) { }
|
||||
}
|
||||
}
|
||||
10
Archive/HaDocument/Exceptions/SettingsInvalidException.cs
Normal file
10
Archive/HaDocument/Exceptions/SettingsInvalidException.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
namespace HaDocument.Exceptions {
|
||||
public class SettingsInvalidException : Exception {
|
||||
public SettingsInvalidException() { }
|
||||
|
||||
public SettingsInvalidException(string msg) : base (msg) { }
|
||||
|
||||
public SettingsInvalidException(string msg, Exception inner) : base (msg, inner) { }
|
||||
}
|
||||
}
|
||||
13
Archive/HaDocument/HaDocument.csproj
Normal file
13
Archive/HaDocument/HaDocument.csproj
Normal file
@@ -0,0 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\HaXMLReader\HaXMLReader.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
</Project>
|
||||
7
Archive/HaDocument/Interfaces/IDocument.cs
Normal file
7
Archive/HaDocument/Interfaces/IDocument.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
using System;
|
||||
|
||||
namespace HaDocument.Interfaces {
|
||||
public interface IDocument {
|
||||
|
||||
}
|
||||
}
|
||||
10
Archive/HaDocument/Interfaces/IHaDocumentOptions.cs
Normal file
10
Archive/HaDocument/Interfaces/IHaDocumentOptions.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
|
||||
namespace HaDocument.Interfaces {
|
||||
public interface IHaDocumentOptions {
|
||||
string HamannXMLFilePath { get; set; }
|
||||
string[] AvailableVolumes { get; set; }
|
||||
bool NormalizeWhitespace { get; set; }
|
||||
(int, int) AvailableYearRange { get; set; }
|
||||
}
|
||||
}
|
||||
31
Archive/HaDocument/Interfaces/ILibrary.cs
Normal file
31
Archive/HaDocument/Interfaces/ILibrary.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Immutable;
|
||||
|
||||
using HaDocument.Models;
|
||||
using System.Linq;
|
||||
|
||||
namespace HaDocument.Interfaces {
|
||||
public interface ILibrary {
|
||||
IHaDocumentOptions Options { get; }
|
||||
ImmutableDictionary<string, Tradition> Traditions { get; }
|
||||
ImmutableDictionary<string, Person> Persons { get; }
|
||||
ImmutableDictionary<string, Meta> Metas { get; }
|
||||
ImmutableDictionary<string, Marginal> Marginals { get; }
|
||||
ImmutableDictionary<string, Location> Locations { get; }
|
||||
ImmutableDictionary<string, Letter> Letters { get; }
|
||||
ImmutableDictionary<string, Person> HandPersons { get; }
|
||||
ImmutableDictionary<string, Editreason> Editreasons { get; }
|
||||
ImmutableDictionary<string, Comment> Comments { get; }
|
||||
ImmutableDictionary<string, ImmutableList<Backlink>> Backlinks { get; }
|
||||
ImmutableDictionary<string, ImmutableList<Hand>> Hands { get; }
|
||||
ImmutableDictionary<string, ImmutableDictionary<string, ImmutableDictionary<string, string>>> Structure { get; }
|
||||
|
||||
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<string, Meta> MetasByYear { get; }
|
||||
ImmutableDictionary<string, Comment> SubCommentsByID { get; }
|
||||
}
|
||||
}
|
||||
7
Archive/HaDocument/Interfaces/ITemporaryLibrary.cs
Normal file
7
Archive/HaDocument/Interfaces/ITemporaryLibrary.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
using System;
|
||||
|
||||
namespace HaDocument {
|
||||
interface ITemporaryLibrary {
|
||||
|
||||
}
|
||||
}
|
||||
16
Archive/HaDocument/Logic/Helpers.cs
Normal file
16
Archive/HaDocument/Logic/Helpers.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using HaXMLReader.EvArgs;
|
||||
using System.Linq;
|
||||
|
||||
namespace HaDocument {
|
||||
static class Helpers {
|
||||
internal static string GetElementString(Tag tag) {
|
||||
var res = "<" + (tag.EndTag ? "/" : "") + tag.Name.ToLower();
|
||||
if (!tag.EndTag && tag.Values != null && tag.Values.Any()) {
|
||||
foreach (var kvp in tag.Values) {
|
||||
res += " " + kvp.Key.ToLower() + "=\"" + kvp.Value.ToLower() + "\"";
|
||||
}
|
||||
}
|
||||
return res + (tag.IsEmpty ? "/" : "") + ">";
|
||||
}
|
||||
}
|
||||
}
|
||||
10
Archive/HaDocument/Logic/SettingsValidator.cs
Normal file
10
Archive/HaDocument/Logic/SettingsValidator.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
using HaDocument.Interfaces;
|
||||
|
||||
namespace HaDocument.Logic {
|
||||
static class SettingsValidator {
|
||||
internal static void Validate(IHaDocumentOptions settings) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
24
Archive/HaDocument/Models/Backlink.cs
Normal file
24
Archive/HaDocument/Models/Backlink.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
namespace HaDocument.Models {
|
||||
public class Backlink {
|
||||
public string Index { get; } = "";
|
||||
|
||||
public string Letter { get; } = "";
|
||||
public string Page { get; } = "";
|
||||
public string Line { get; } = "";
|
||||
public string MarginalIndex { get; } = "";
|
||||
|
||||
public Backlink(
|
||||
string index,
|
||||
string letter,
|
||||
string page,
|
||||
string line,
|
||||
string marginalindex
|
||||
) {
|
||||
Index = index;
|
||||
Letter = letter;
|
||||
Page = page;
|
||||
Line = line;
|
||||
MarginalIndex = marginalindex;
|
||||
}
|
||||
}
|
||||
}
|
||||
36
Archive/HaDocument/Models/Comment.cs
Normal file
36
Archive/HaDocument/Models/Comment.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
|
||||
namespace HaDocument.Models {
|
||||
public class Comment{
|
||||
public string Entry { get; } = "";
|
||||
public string Index { get; } = "";
|
||||
public string Type { get; } = "";
|
||||
public string Lemma { get; } = "";
|
||||
public string Parent { get; } = "";
|
||||
public int Order { get; } = -1;
|
||||
public ImmutableSortedDictionary<string, Comment> Kommentare { get; }
|
||||
|
||||
public Comment(
|
||||
string entry,
|
||||
string index,
|
||||
string type,
|
||||
string lemma,
|
||||
int order,
|
||||
SortedDictionary<string, Comment> subComments,
|
||||
string parent=""
|
||||
) {
|
||||
Entry = entry;
|
||||
Index = index;
|
||||
Type = type;
|
||||
Lemma = lemma;
|
||||
Order = order;
|
||||
Parent = parent;
|
||||
if (subComments != null)
|
||||
Kommentare = ImmutableSortedDictionary.ToImmutableSortedDictionary(subComments);
|
||||
else
|
||||
Kommentare = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
32
Archive/HaDocument/Models/Editreason.cs
Normal file
32
Archive/HaDocument/Models/Editreason.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
namespace HaDocument.Models {
|
||||
public class Editreason {
|
||||
public string Index { get; } = "";
|
||||
public string Element { get; } = "";
|
||||
public string Letter { get; } = "";
|
||||
public string StartPage { get; } = "";
|
||||
public string StartLine { get; } = "";
|
||||
public string EndPage { get; } = "";
|
||||
public string EndLine { get; } = "";
|
||||
public string Reference { get; } = "";
|
||||
|
||||
public Editreason(
|
||||
string index,
|
||||
string element,
|
||||
string letter = "",
|
||||
string startpage = "",
|
||||
string startline = "",
|
||||
string endpage = "",
|
||||
string endline = "",
|
||||
string reference = ""
|
||||
) {
|
||||
Index = index;
|
||||
Element = element;
|
||||
Letter = letter;
|
||||
StartPage = startpage;
|
||||
StartLine = startline;
|
||||
EndPage = endpage;
|
||||
EndLine = endline;
|
||||
Reference = reference;
|
||||
}
|
||||
}
|
||||
}
|
||||
15
Archive/HaDocument/Models/HaModel.cs
Normal file
15
Archive/HaDocument/Models/HaModel.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
26
Archive/HaDocument/Models/Hand.cs
Normal file
26
Archive/HaDocument/Models/Hand.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
namespace HaDocument.Models {
|
||||
public class Hand : HaModel {
|
||||
public string Letter { get; } = "";
|
||||
public string Person { get; } = "";
|
||||
public string StartPage { get; } = "";
|
||||
public string StartLine { get; } = "";
|
||||
public string EndPage { get; } = "";
|
||||
public string EndLine {get; } = "";
|
||||
|
||||
public Hand(
|
||||
string letter,
|
||||
string person,
|
||||
string startpage,
|
||||
string startline,
|
||||
string endpage,
|
||||
string endline
|
||||
) {
|
||||
Letter = letter;
|
||||
Person = person;
|
||||
StartPage = startpage;
|
||||
StartLine = startline;
|
||||
EndPage = endpage;
|
||||
EndLine = endline;
|
||||
}
|
||||
}
|
||||
}
|
||||
70
Archive/HaDocument/Models/IntermediateLibrary.cs
Normal file
70
Archive/HaDocument/Models/IntermediateLibrary.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using System.Collections.Generic;
|
||||
using HaDocument.Interfaces;
|
||||
|
||||
namespace HaDocument.Models
|
||||
{
|
||||
public class IntermediateLibrary
|
||||
{
|
||||
public Dictionary<string, Tradition> Traditions;
|
||||
public Dictionary<string, Person> Persons;
|
||||
public Dictionary<string, Meta> Metas;
|
||||
public Dictionary<string, Marginal> Marginals;
|
||||
public Dictionary<string, Location> Locations;
|
||||
public Dictionary<string, Letter> Letters;
|
||||
public Dictionary<string, Person> HandPersons;
|
||||
public Dictionary<string, Editreason> Editreasons;
|
||||
public Dictionary<string, Comment> Comments;
|
||||
public Dictionary<string, List<Backlink>> Backlinks;
|
||||
public Dictionary<string, List<Hand>> Hands;
|
||||
|
||||
// Helper Library for precalculationg the Structure of the Document:
|
||||
public Dictionary<string, Dictionary<string, HashSet<string>>> LetterPageLines;
|
||||
|
||||
public Library GetLibrary(IHaDocumentOptions options)
|
||||
{
|
||||
var Structure = new Dictionary<string, Dictionary<string, Dictionary<string, string>>>();
|
||||
foreach (var letter in LetterPageLines)
|
||||
{
|
||||
if (Metas.ContainsKey(letter.Key) &&
|
||||
Metas[letter.Key].ZH != null)
|
||||
{
|
||||
if (!Structure.ContainsKey(Metas[letter.Key].ZH.Volume))
|
||||
{
|
||||
Structure.Add(Metas[letter.Key].ZH.Volume, new Dictionary<string, Dictionary<string, string>>());
|
||||
}
|
||||
foreach (var page in letter.Value)
|
||||
{
|
||||
if (!Structure[Metas[letter.Key].ZH.Volume].ContainsKey(page.Key))
|
||||
{
|
||||
Structure[Metas[letter.Key].ZH.Volume].Add(page.Key, new Dictionary<string, string>());
|
||||
}
|
||||
foreach (var line in page.Value)
|
||||
{
|
||||
if (!Structure[Metas[letter.Key].ZH.Volume][page.Key].ContainsKey(line))
|
||||
{
|
||||
Structure[Metas[letter.Key].ZH.Volume][page.Key].Add(line, letter.Key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return new Library(
|
||||
Traditions,
|
||||
Persons,
|
||||
Metas,
|
||||
Marginals,
|
||||
Locations,
|
||||
Letters,
|
||||
HandPersons,
|
||||
Editreasons,
|
||||
Comments,
|
||||
Backlinks,
|
||||
Hands,
|
||||
Structure,
|
||||
options
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
14
Archive/HaDocument/Models/Letter.cs
Normal file
14
Archive/HaDocument/Models/Letter.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
namespace HaDocument.Models {
|
||||
public class Letter : HaModel {
|
||||
public string Index { get; } = "";
|
||||
public string Element { get; } = "";
|
||||
|
||||
public Letter(
|
||||
string index,
|
||||
string element
|
||||
) {
|
||||
Index = index;
|
||||
Element = element;
|
||||
}
|
||||
}
|
||||
}
|
||||
150
Archive/HaDocument/Models/Library.cs
Normal file
150
Archive/HaDocument/Models/Library.cs
Normal file
@@ -0,0 +1,150 @@
|
||||
using System;
|
||||
using HaDocument.Interfaces;
|
||||
using System.Collections.Immutable;
|
||||
using System.Collections.Generic;
|
||||
using HaDocument.Models;
|
||||
using HaDocument.Comparers;
|
||||
using System.Linq;
|
||||
|
||||
namespace HaDocument.Models
|
||||
{
|
||||
public class Library : ILibrary
|
||||
{
|
||||
public IHaDocumentOptions Options { get; }
|
||||
public ImmutableDictionary<string, Tradition> Traditions { get; }
|
||||
public ImmutableDictionary<string, Person> Persons { get; }
|
||||
public ImmutableDictionary<string, Meta> Metas { get; }
|
||||
public ImmutableDictionary<string, Marginal> Marginals { get; }
|
||||
public ImmutableDictionary<string, Location> Locations { get; }
|
||||
public ImmutableDictionary<string, Letter> Letters { get; }
|
||||
public ImmutableDictionary<string, Person> HandPersons { get; }
|
||||
public ImmutableDictionary<string, Editreason> Editreasons { get; }
|
||||
public ImmutableDictionary<string, Comment> Comments { get; }
|
||||
public ImmutableDictionary<string, ImmutableList<Backlink>> Backlinks { get; }
|
||||
public ImmutableDictionary<string, ImmutableList<Hand>> Hands { get; }
|
||||
|
||||
// Structure for lookups from ZH:
|
||||
public ImmutableDictionary<string, ImmutableDictionary<string, ImmutableDictionary<string, string>>> Structure { get; }
|
||||
|
||||
// Lookups:
|
||||
// Auswählen von Kommentaren nach (1) Kategorie, (2) Anfangsbuchstaben vom Lemma.
|
||||
// So: _ = CommentsByCategoryLetter['neuzeit']['A']
|
||||
public ImmutableDictionary<string, Lookup<string, Comment>> CommentsByCategoryLetter { get; }
|
||||
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.
|
||||
public ImmutableSortedSet<Meta> MetasByDate { get; }
|
||||
// Auswählen von Briefen nach dem Jahr, sortiert nach Datum
|
||||
public ILookup<string, Meta> MetasByYear { get; }
|
||||
|
||||
|
||||
public Library(
|
||||
Dictionary<string, Tradition> traditions,
|
||||
Dictionary<string, Person> persons,
|
||||
Dictionary<string, Meta> meta,
|
||||
Dictionary<string, Marginal> marginals,
|
||||
Dictionary<string, Location> locations,
|
||||
Dictionary<string, Letter> letters,
|
||||
Dictionary<string, Person> handPersons,
|
||||
Dictionary<string, Editreason> editReasons,
|
||||
Dictionary<string, Comment> comments,
|
||||
Dictionary<string, List<Backlink>> backlinks,
|
||||
Dictionary<string, List<Hand>> hands,
|
||||
Dictionary<string, Dictionary<string, Dictionary<string, string>>> Structure,
|
||||
IHaDocumentOptions options
|
||||
)
|
||||
{
|
||||
// Dictionaries
|
||||
Traditions = ImmutableDictionary.ToImmutableDictionary(traditions);
|
||||
Persons = ImmutableDictionary.ToImmutableDictionary(persons);
|
||||
Metas = ImmutableDictionary.ToImmutableDictionary(meta);
|
||||
Marginals = ImmutableDictionary.ToImmutableDictionary(marginals);
|
||||
Locations = ImmutableDictionary.ToImmutableDictionary(locations);
|
||||
Letters = ImmutableDictionary.ToImmutableDictionary(letters);
|
||||
HandPersons = ImmutableDictionary.ToImmutableDictionary(handPersons);
|
||||
Editreasons = ImmutableDictionary.ToImmutableDictionary(editReasons);
|
||||
Comments = ImmutableDictionary.ToImmutableDictionary(comments);
|
||||
|
||||
var backbuilder = ImmutableDictionary.CreateBuilder<string, ImmutableList<Backlink>>();
|
||||
foreach (var entry in backlinks)
|
||||
backbuilder.Add(entry.Key, ImmutableList.ToImmutableList(entry.Value));
|
||||
Backlinks = backbuilder.ToImmutableDictionary();
|
||||
|
||||
var handbuilder = ImmutableDictionary.CreateBuilder<string, ImmutableList<Hand>>();
|
||||
foreach (var entry in hands)
|
||||
handbuilder.Add(entry.Key, ImmutableList.ToImmutableList(entry.Value));
|
||||
Hands = handbuilder.ToImmutableDictionary();
|
||||
|
||||
// Lookups
|
||||
CommentsByCategory = (Lookup<string, Comment>)Comments.Values.ToLookup(x => x.Type);
|
||||
var CommentsByLetter_builder = ImmutableDictionary.CreateBuilder<string, Lookup<string, Comment>>();
|
||||
foreach (var ts in CommentsByCategory)
|
||||
{
|
||||
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.ToString());
|
||||
|
||||
var tempbuilder = ImmutableDictionary.CreateBuilder<string, Comment>();
|
||||
foreach (var comm in Comments)
|
||||
if (comm.Value.Kommentare != null)
|
||||
foreach (var subcomm in comm.Value.Kommentare)
|
||||
if (!tempbuilder.ContainsKey(subcomm.Key))
|
||||
tempbuilder.Add(subcomm.Key, subcomm.Value);
|
||||
SubCommentsByID = tempbuilder.ToImmutableDictionary();
|
||||
|
||||
var tempstructurebuilder = ImmutableDictionary.CreateBuilder<string, ImmutableDictionary<string, ImmutableDictionary<string, string>>>();
|
||||
foreach (var volume in Structure)
|
||||
{
|
||||
if (volume.Value != null)
|
||||
{
|
||||
var tempvolbuilder = ImmutableDictionary.CreateBuilder<string, ImmutableDictionary<string, string>>();
|
||||
foreach (var page in volume.Value)
|
||||
{
|
||||
if (page.Value != null)
|
||||
{
|
||||
tempvolbuilder.Add(page.Key, page.Value.ToImmutableDictionary());
|
||||
}
|
||||
}
|
||||
if (tempvolbuilder.Any())
|
||||
{
|
||||
tempstructurebuilder.Add(volume.Key, tempvolbuilder.ToImmutableDictionary());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.Structure = tempstructurebuilder.ToImmutableDictionary();
|
||||
|
||||
Options = options;
|
||||
|
||||
}
|
||||
|
||||
// public List<Meta> MetasByDate() {
|
||||
// var ret = Metas.OrderBy(x => x.Value, new DefaultComparer()).ToLookup(x => x.Value.Autopsic, x => x.Value);
|
||||
// ret.Sort(new DefaultComparer());
|
||||
// return ret;
|
||||
// }
|
||||
|
||||
public ImmutableList<Meta> MetasByZH()
|
||||
{
|
||||
return Metas.Values.ToImmutableList().Sort(new Comparers.ZHComparer());
|
||||
}
|
||||
|
||||
public List<Person> PersonByAlphabet()
|
||||
{
|
||||
var ret = Persons.Values.ToList();
|
||||
ret.Sort(new PersonComparer());
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
14
Archive/HaDocument/Models/Location.cs
Normal file
14
Archive/HaDocument/Models/Location.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
namespace HaDocument.Models {
|
||||
public class Location {
|
||||
public string Index { get; } = "";
|
||||
public string Name { get; } = "";
|
||||
|
||||
public Location(
|
||||
string index,
|
||||
string name
|
||||
) {
|
||||
Index = index;
|
||||
Name = name;
|
||||
}
|
||||
}
|
||||
}
|
||||
23
Archive/HaDocument/Models/Marginal.cs
Normal file
23
Archive/HaDocument/Models/Marginal.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
namespace HaDocument.Models {
|
||||
public class Marginal {
|
||||
public string Index { get; } = "";
|
||||
public string Letter { get; } = "";
|
||||
public string Page { get; } = "";
|
||||
public string Line { get; } = "";
|
||||
public string Element { get; } = "";
|
||||
|
||||
public Marginal(
|
||||
string index,
|
||||
string letter,
|
||||
string page,
|
||||
string line,
|
||||
string elemnt
|
||||
) {
|
||||
Index = index;
|
||||
Letter = letter;
|
||||
Page = page;
|
||||
Line = line;
|
||||
Element = elemnt;
|
||||
}
|
||||
}
|
||||
}
|
||||
49
Archive/HaDocument/Models/Meta.cs
Normal file
49
Archive/HaDocument/Models/Meta.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using HaXMLReader.EvArgs;
|
||||
|
||||
namespace HaDocument.Models {
|
||||
public class Meta {
|
||||
public string Index { get; } = "";
|
||||
public string Autopsic { 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 ZHInfo ZH { get; } = null;
|
||||
|
||||
public Meta(
|
||||
string index,
|
||||
string autopsic,
|
||||
string date,
|
||||
DateTime sort,
|
||||
int order,
|
||||
OptionalBool hasOriginal,
|
||||
OptionalBool isProofread,
|
||||
OptionalBool isDraft,
|
||||
string location,
|
||||
List<string> senders,
|
||||
List<string> receivers,
|
||||
ZHInfo ZH
|
||||
) {
|
||||
Index = index;
|
||||
Autopsic = autopsic;
|
||||
Date = date;
|
||||
Sort = sort;
|
||||
Order = order;
|
||||
Location = location;
|
||||
Senders = senders;
|
||||
Receivers = receivers;
|
||||
this.hasOriginal = hasOriginal;
|
||||
this.isProofread = isProofread;
|
||||
this.isDraft = isDraft;
|
||||
this.ZH = ZH;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
13
Archive/HaDocument/Models/OptionalBool.cs
Normal file
13
Archive/HaDocument/Models/OptionalBool.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace HaDocument.Models
|
||||
{
|
||||
public enum OptionalBool
|
||||
{
|
||||
True,
|
||||
False,
|
||||
None
|
||||
}
|
||||
}
|
||||
20
Archive/HaDocument/Models/Person.cs
Normal file
20
Archive/HaDocument/Models/Person.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
namespace HaDocument.Models {
|
||||
public class Person {
|
||||
public string Index { get; } = "";
|
||||
public string Name { get; } = "";
|
||||
public string Prename { get; } = "";
|
||||
public string Surname { get; } = "";
|
||||
|
||||
public Person(
|
||||
string index,
|
||||
string name,
|
||||
string prename,
|
||||
string surname
|
||||
) {
|
||||
Index = index;
|
||||
Name = name;
|
||||
Prename = prename;
|
||||
Surname = surname;
|
||||
}
|
||||
}
|
||||
}
|
||||
14
Archive/HaDocument/Models/Tradition.cs
Normal file
14
Archive/HaDocument/Models/Tradition.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
namespace HaDocument.Models {
|
||||
public class Tradition {
|
||||
public string Index { get; } = "";
|
||||
public string Element { get; } = "";
|
||||
|
||||
public Tradition(
|
||||
string index,
|
||||
string element
|
||||
) {
|
||||
Index = index;
|
||||
Element = element;
|
||||
}
|
||||
}
|
||||
}
|
||||
22
Archive/HaDocument/Models/ZHInfo.cs
Normal file
22
Archive/HaDocument/Models/ZHInfo.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace HaDocument.Models
|
||||
{
|
||||
|
||||
public class ZHInfo
|
||||
{
|
||||
public bool alternativeLineNumbering { get; } = false;
|
||||
public bool dateChanged { get; } = false;
|
||||
public string Volume { get; } = "";
|
||||
public string Page { get; } = "";
|
||||
|
||||
public ZHInfo(bool alternativeLineNumbering, bool dateChanged, string Volume, string Page) {
|
||||
this.alternativeLineNumbering = alternativeLineNumbering;
|
||||
this.dateChanged = dateChanged;
|
||||
this.Volume = Volume;
|
||||
this.Page = Page;
|
||||
}
|
||||
}
|
||||
}
|
||||
178
Archive/HaDocument/Reactors/CommentReactor.cs
Normal file
178
Archive/HaDocument/Reactors/CommentReactor.cs
Normal file
@@ -0,0 +1,178 @@
|
||||
using HaXMLReader.Interfaces;
|
||||
using HaXMLReader.EvArgs;
|
||||
using HaDocument.Models;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using HaDocument.Comparers;
|
||||
|
||||
namespace HaDocument.Reactors {
|
||||
class CommentReactor : Reactor {
|
||||
|
||||
Dictionary<string, Comment> CreatedInstances;
|
||||
|
||||
private bool _normalizeWhitespace = false;
|
||||
|
||||
// State
|
||||
private string Type = "";
|
||||
private string Index = "";
|
||||
private string Lemma = "";
|
||||
private string Entry = "";
|
||||
private int Order = -1;
|
||||
private SortedDictionary<string, Comment> Subcomments;
|
||||
|
||||
private bool subsection = false;
|
||||
private string subsectionIndex = "";
|
||||
private string subsectionLemma = "";
|
||||
private string subsectionEntry = "";
|
||||
private int subsectionOrder = -1;
|
||||
|
||||
internal CommentReactor(IReader reader, IntermediateLibrary lib, bool normalizeWhitespace) : base(reader, lib) {
|
||||
_normalizeWhitespace = normalizeWhitespace;
|
||||
_lib.Comments = _lib.Comments ?? new Dictionary<string, Comment>();
|
||||
CreatedInstances = _lib.Comments;
|
||||
reader.OpenTag += Listen;
|
||||
}
|
||||
|
||||
protected override void Listen(object _, Tag tag) {
|
||||
if (
|
||||
!tag.IsEmpty &&
|
||||
!tag.EndTag &&
|
||||
tag.Name == "kommcat" &&
|
||||
!string.IsNullOrWhiteSpace(tag["value"])
|
||||
) {
|
||||
Type = tag["value"];
|
||||
Activate(_reader, tag);
|
||||
}
|
||||
else if (
|
||||
tag.EndTag &&
|
||||
tag.Name == "kommcat"
|
||||
) {
|
||||
ResetType();
|
||||
Deactivate();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Activate(IReader _, Tag tag) {
|
||||
_reader.Tag += OnTag;
|
||||
}
|
||||
|
||||
private void OnTag(object _, Tag tag) {
|
||||
if (
|
||||
!tag.IsEmpty &&
|
||||
!tag.EndTag &&
|
||||
tag.Name == "kommentar" &&
|
||||
!string.IsNullOrWhiteSpace(tag["id"])
|
||||
) {
|
||||
Index = tag["id"];
|
||||
Order = String.IsNullOrWhiteSpace(tag["sort"]) ? 0 : Int32.Parse(tag["sort"]);
|
||||
}
|
||||
else if (
|
||||
tag.EndTag &&
|
||||
tag.Name == "kommentar"
|
||||
) {
|
||||
AddComment();
|
||||
}
|
||||
else if (
|
||||
!tag.EndTag &&
|
||||
!tag.IsEmpty &&
|
||||
tag.Name == "lemma"
|
||||
) {
|
||||
_ = new ElementStringBinder(_reader, tag, AddLemma, _normalizeWhitespace);
|
||||
}
|
||||
else if (
|
||||
!tag.EndTag &&
|
||||
!tag.IsEmpty &&
|
||||
tag.Name == "eintrag"
|
||||
) {
|
||||
_ = new ElementStringBinder(_reader, tag, AddEntry, _normalizeWhitespace);
|
||||
}
|
||||
else if (
|
||||
!tag.EndTag &&
|
||||
!tag.IsEmpty &&
|
||||
tag.Name == "subsection"
|
||||
) {
|
||||
if (!String.IsNullOrWhiteSpace(tag["id"])) subsectionIndex = tag["id"];
|
||||
if (!String.IsNullOrWhiteSpace(tag["sort"])) subsectionOrder = Int32.Parse(tag["sort"]);
|
||||
if (Subcomments ==null) Subcomments = new SortedDictionary<string, Comment>();
|
||||
subsection = true;
|
||||
}
|
||||
else if (
|
||||
tag.EndTag &&
|
||||
tag.Name == "subsection"
|
||||
) {
|
||||
subsection = false;
|
||||
AddSubsection();
|
||||
}
|
||||
}
|
||||
|
||||
private void Deactivate() {
|
||||
_reader.Tag -= OnTag;
|
||||
}
|
||||
|
||||
private void AddLemma(string str) {
|
||||
if (String.IsNullOrEmpty(str)) return;
|
||||
if (subsection) subsectionLemma = str;
|
||||
else Lemma = str;
|
||||
}
|
||||
|
||||
private void AddEntry(string str) {
|
||||
if (String.IsNullOrWhiteSpace(str)) str = "";
|
||||
if (subsection) subsectionEntry = str;
|
||||
else Entry = str;
|
||||
}
|
||||
|
||||
private void AddSubsection() {
|
||||
if (String.IsNullOrWhiteSpace(subsectionIndex)) return;
|
||||
if (String.IsNullOrWhiteSpace(subsectionLemma)) return;
|
||||
if (!Subcomments.ContainsKey(subsectionIndex))
|
||||
{
|
||||
Subcomments.Add(subsectionIndex, new Comment(
|
||||
subsectionEntry,
|
||||
subsectionIndex,
|
||||
Type,
|
||||
subsectionLemma,
|
||||
subsectionOrder,
|
||||
null,
|
||||
Index
|
||||
));
|
||||
}
|
||||
ResetSubsection();
|
||||
}
|
||||
|
||||
private void AddComment() {
|
||||
if (String.IsNullOrWhiteSpace(Index)) return;
|
||||
if (String.IsNullOrWhiteSpace(Lemma)) return;
|
||||
if (CreatedInstances.ContainsKey(Index)) return;
|
||||
CreatedInstances.Add(Index, new Comment(
|
||||
Entry,
|
||||
Index,
|
||||
Type,
|
||||
Lemma,
|
||||
Order,
|
||||
Subcomments
|
||||
));
|
||||
Reset();
|
||||
}
|
||||
|
||||
protected override void Reset() {
|
||||
Index = "";
|
||||
Lemma = "";
|
||||
Entry = "";
|
||||
Order = -1;
|
||||
Subcomments = null;
|
||||
ResetSubsection();
|
||||
}
|
||||
|
||||
private void ResetSubsection() {
|
||||
subsection = false;
|
||||
subsectionEntry = "";
|
||||
subsectionIndex = "";
|
||||
subsectionLemma = "";
|
||||
subsectionOrder = -1;
|
||||
}
|
||||
|
||||
private void ResetType() {
|
||||
Type = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
154
Archive/HaDocument/Reactors/EditreasonReactor.cs
Normal file
154
Archive/HaDocument/Reactors/EditreasonReactor.cs
Normal file
@@ -0,0 +1,154 @@
|
||||
using HaDocument.Models;
|
||||
using System.Collections.Generic;
|
||||
using HaXMLReader.EvArgs;
|
||||
using HaXMLReader.Interfaces;
|
||||
using System;
|
||||
|
||||
namespace HaDocument.Reactors {
|
||||
class EditreasonReactor : Reactor {
|
||||
internal Dictionary<string, Editreason> CreatedInstances;
|
||||
|
||||
private Dictionary<string, string[]> _intermediateReasons = new Dictionary<string, string[]>();
|
||||
private bool _normalizeWhitespace = false;
|
||||
|
||||
// State
|
||||
private string Index = "";
|
||||
|
||||
private string letter = "";
|
||||
private string page = "";
|
||||
private string line = "";
|
||||
private Stack<string> index;
|
||||
|
||||
private ElementStringBinder _element = null;
|
||||
|
||||
internal EditreasonReactor(IReader reader, IntermediateLibrary lib, bool normalizeWhitespace) : base (reader, lib) {
|
||||
CreatedInstances = lib.Editreasons;
|
||||
index = new Stack<string>();
|
||||
_normalizeWhitespace = normalizeWhitespace;
|
||||
lib.Editreasons = new Dictionary<string, Editreason>();
|
||||
CreatedInstances = lib.Editreasons;
|
||||
reader.Tag += Listen;
|
||||
reader.ReadingStop += Scaffold;
|
||||
}
|
||||
|
||||
protected void Scaffold(object _, EventArgs __) {
|
||||
foreach (var entry in _intermediateReasons) {
|
||||
if (
|
||||
!String.IsNullOrWhiteSpace(entry.Value[0]) &&
|
||||
!String.IsNullOrWhiteSpace(entry.Value[1]) &&
|
||||
!String.IsNullOrWhiteSpace(entry.Value[2]) &&
|
||||
!String.IsNullOrWhiteSpace(entry.Value[3])
|
||||
) {
|
||||
CreatedInstances.Add(
|
||||
entry.Key,
|
||||
new Editreason(
|
||||
entry.Key,
|
||||
entry.Value[0],
|
||||
entry.Value[1],
|
||||
entry.Value[2],
|
||||
entry.Value[3],
|
||||
entry.Value[5],
|
||||
entry.Value[6],
|
||||
entry.Value[4]
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Listen(object sender, Tag tag) {
|
||||
if (
|
||||
!tag.EndTag &&
|
||||
!tag.IsEmpty &&
|
||||
tag.Name == "editreason" &&
|
||||
!String.IsNullOrWhiteSpace(tag["index"])
|
||||
) {
|
||||
Activate(_reader, tag);
|
||||
}
|
||||
else if (
|
||||
!tag.EndTag &&
|
||||
!tag.IsEmpty &&
|
||||
tag.Name == "letterText"
|
||||
) {
|
||||
letter = tag["index"];
|
||||
}
|
||||
else if (
|
||||
!tag.EndTag &&
|
||||
!tag.IsEmpty &&
|
||||
tag.Name == "letterTradition"
|
||||
) {
|
||||
letter = tag["ref"];
|
||||
}
|
||||
else if (
|
||||
!tag.EndTag &&
|
||||
tag.IsEmpty &&
|
||||
tag.Name == "page"
|
||||
) {
|
||||
page = tag["index"];
|
||||
}
|
||||
else if (
|
||||
!tag.EndTag &&
|
||||
tag.IsEmpty &&
|
||||
tag.Name == "line"
|
||||
) {
|
||||
line = tag["index"];
|
||||
}
|
||||
else if (
|
||||
!tag.EndTag &&
|
||||
tag.Name == "edit" &&
|
||||
!String.IsNullOrWhiteSpace(tag["ref"])
|
||||
) {
|
||||
if (!_intermediateReasons.ContainsKey(tag["ref"])) {
|
||||
_intermediateReasons.Add(tag["ref"], new string[7]);
|
||||
}
|
||||
_intermediateReasons[tag["ref"]][1] = letter;
|
||||
_intermediateReasons[tag["ref"]][2] = page;
|
||||
_intermediateReasons[tag["ref"]][3] = line;
|
||||
if (!tag.IsEmpty) {
|
||||
index.Push(tag["ref"]);
|
||||
new ElementStringBinder(_reader, tag, AddReference);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Activate(IReader reader, Tag tag) {
|
||||
if (!_active && reader != null && tag != null) {
|
||||
_active = true;
|
||||
_reader = reader;
|
||||
Index = tag["index"];
|
||||
_element = new ElementStringBinder(reader, tag, Add, _normalizeWhitespace);
|
||||
}
|
||||
}
|
||||
|
||||
private void Add(string element) {
|
||||
if (String.IsNullOrWhiteSpace(element)) return;
|
||||
if (!_intermediateReasons.ContainsKey(Index)) {
|
||||
_intermediateReasons.Add(Index, new string[7]);
|
||||
}
|
||||
_intermediateReasons[Index][0] = element;
|
||||
Reset();
|
||||
}
|
||||
|
||||
private void AddReference(string element) {
|
||||
if (String.IsNullOrWhiteSpace(element)) return;
|
||||
var ci = index.Pop();
|
||||
if (!_intermediateReasons.ContainsKey(ci)) {
|
||||
_intermediateReasons.Add(ci, new string[7]);
|
||||
}
|
||||
_intermediateReasons[ci][4] = element;
|
||||
_intermediateReasons[ci][5] = page;
|
||||
_intermediateReasons[ci][6] = line;
|
||||
}
|
||||
|
||||
protected override void Reset() {
|
||||
Index = "";
|
||||
_active = false;
|
||||
_element = null;
|
||||
}
|
||||
|
||||
protected void Deactivate() {
|
||||
_element.Unsubscribe();
|
||||
Reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
99
Archive/HaDocument/Reactors/ElementStringBinder.cs
Normal file
99
Archive/HaDocument/Reactors/ElementStringBinder.cs
Normal file
@@ -0,0 +1,99 @@
|
||||
using System;
|
||||
using HaDocument.Models;
|
||||
using HaXMLReader.EvArgs;
|
||||
using HaXMLReader.Interfaces;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace HaDocument.Reactors {
|
||||
class ElementStringBinder {
|
||||
private StringBuilder _stringBuilder;
|
||||
private XmlWriter _txtwriter;
|
||||
private Stack<Tag> _stack;
|
||||
private IReader _reader;
|
||||
private Action<string> _callback;
|
||||
|
||||
private bool _normalizeWhitespace = false;
|
||||
|
||||
internal ElementStringBinder(IReader reader, Tag start, Action<string> callback) {
|
||||
_reader = reader;
|
||||
_callback = callback;
|
||||
_stack = new Stack<Tag>();
|
||||
_stringBuilder = new StringBuilder();
|
||||
_txtwriter = XmlWriter.Create(_stringBuilder, new XmlWriterSettings() {
|
||||
CheckCharacters = false,
|
||||
ConformanceLevel = ConformanceLevel.Fragment,
|
||||
Encoding = Encoding.UTF8,
|
||||
OmitXmlDeclaration = true,
|
||||
NewLineHandling = NewLineHandling.None
|
||||
});
|
||||
_stack.Push(start);
|
||||
_writeTag(start);
|
||||
Subscribe();
|
||||
}
|
||||
|
||||
internal ElementStringBinder(IReader reader, Tag start, Action<string> callback, bool normalizeWhitespace) : this(reader, start, callback) {
|
||||
_normalizeWhitespace = normalizeWhitespace;
|
||||
}
|
||||
|
||||
internal void Subscribe() {
|
||||
_reader.Tag += OnTag;
|
||||
_reader.Text += OnText;
|
||||
_reader.Whitespace += OnWhiteSpace;
|
||||
}
|
||||
|
||||
internal void Unsubscribe() {
|
||||
_reader.Tag -= OnTag;
|
||||
_reader.Text -= OnText;
|
||||
_reader.Whitespace -= OnWhiteSpace;
|
||||
}
|
||||
|
||||
internal string GetElementText() {
|
||||
_txtwriter.Flush();
|
||||
_txtwriter.Dispose();
|
||||
Unsubscribe();
|
||||
var ret = _stringBuilder.ToString();
|
||||
_stringBuilder = new StringBuilder();
|
||||
return ret;
|
||||
}
|
||||
|
||||
private void _writeTag(Tag tag) {
|
||||
var writer = _txtwriter;
|
||||
if (tag.EndTag) {
|
||||
writer.WriteEndElement();
|
||||
return;
|
||||
}
|
||||
writer.WriteStartElement(tag.Name);
|
||||
if (tag.Values != null && tag.Values.Count > 0)
|
||||
foreach (var kv in tag.Values)
|
||||
writer.WriteAttributeString(kv.Key, kv.Value);
|
||||
if ( tag.IsEmpty )
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
|
||||
private void OnTag(object _, Tag tag) {
|
||||
_writeTag(tag);
|
||||
if (!tag.IsEmpty && tag.EndTag) _stack.Pop();
|
||||
else if (!tag.IsEmpty) _stack.Push(tag);
|
||||
if (_stack.Count == 0 ) _callback(GetElementText());
|
||||
}
|
||||
|
||||
private void OnText(object _, Text text) {
|
||||
if (_normalizeWhitespace) {
|
||||
var neu = text.Value.Replace('\n', ' ').Replace("\t", "").Replace("\r", "");
|
||||
_txtwriter.WriteString(neu);
|
||||
}
|
||||
else
|
||||
_txtwriter.WriteString(text.Value);
|
||||
}
|
||||
|
||||
private void OnWhiteSpace(object _, Whitespace ws) {
|
||||
if (_normalizeWhitespace)
|
||||
_txtwriter.WriteWhitespace(" ");
|
||||
else
|
||||
_txtwriter.WriteWhitespace(ws.Value);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
55
Archive/HaDocument/Reactors/HandDefsReactor.cs
Normal file
55
Archive/HaDocument/Reactors/HandDefsReactor.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
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 HandDefsReactor : Reactor {
|
||||
internal Dictionary<string, Person> CreatedInstances;
|
||||
|
||||
// State
|
||||
private string Index;
|
||||
private string Name;
|
||||
|
||||
internal HandDefsReactor(IReader reader, IntermediateLibrary lib) : base(reader, lib) {
|
||||
lib.HandPersons = new Dictionary<string, Person>();
|
||||
CreatedInstances = lib.HandPersons;
|
||||
reader.Tag += Listen;
|
||||
}
|
||||
|
||||
protected override void Listen(object sender, Tag tag) {
|
||||
if (
|
||||
!tag.EndTag &&
|
||||
tag.IsEmpty &&
|
||||
tag.Name == "handDef" &&
|
||||
!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"];
|
||||
Add();
|
||||
_active = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Reset() {
|
||||
Index = "";
|
||||
Name = "";
|
||||
}
|
||||
|
||||
protected void Add() {
|
||||
CreatedInstances.Add(Index, new Person(Index, Name, "", ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
151
Archive/HaDocument/Reactors/LetterReactor.cs
Normal file
151
Archive/HaDocument/Reactors/LetterReactor.cs
Normal file
@@ -0,0 +1,151 @@
|
||||
using System;
|
||||
using HaXMLReader.EvArgs;
|
||||
using HaXMLReader.Interfaces;
|
||||
using HaDocument.Models;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.Linq;
|
||||
|
||||
namespace HaDocument.Reactors
|
||||
{
|
||||
class LetterReactor : Reactor
|
||||
{
|
||||
internal Dictionary<string, Letter> CreatedInstances;
|
||||
internal Dictionary<string, List<Hand>> CreatedHands;
|
||||
internal Dictionary<string, Dictionary<string, HashSet<string>>> CreatedStructure;
|
||||
|
||||
// State
|
||||
private string Index = "";
|
||||
private ElementStringBinder _element = null;
|
||||
|
||||
private bool _normalizeWhitespace = false;
|
||||
private string _page = "";
|
||||
private string _line = "";
|
||||
private List<Hand> _hands;
|
||||
private string _person = "";
|
||||
private string _handstartpg = "";
|
||||
private string _handstartln = "";
|
||||
|
||||
internal LetterReactor(IReader reader, IntermediateLibrary lib, bool normalizeWhitespace) : base(reader, lib)
|
||||
{
|
||||
_normalizeWhitespace = normalizeWhitespace;
|
||||
lib.Letters = new Dictionary<string, Letter>();
|
||||
if (lib.Hands == null)
|
||||
lib.Hands = new Dictionary<string, List<Hand>>();
|
||||
if (lib.LetterPageLines == null)
|
||||
lib.LetterPageLines = new Dictionary<string, Dictionary<string, HashSet<string>>>();
|
||||
CreatedHands = lib.Hands;
|
||||
CreatedInstances = lib.Letters;
|
||||
CreatedStructure = lib.LetterPageLines;
|
||||
reader.OpenTag += Listen;
|
||||
reader.SingleTag += Listen;
|
||||
reader.CloseTag += Listen;
|
||||
}
|
||||
|
||||
protected override void Listen(object sender, Tag tag)
|
||||
{
|
||||
if (
|
||||
!tag.EndTag &&
|
||||
!tag.IsEmpty &&
|
||||
tag.Name == "letterText" &&
|
||||
!String.IsNullOrWhiteSpace(tag["index"])
|
||||
)
|
||||
{
|
||||
Activate(_reader, tag);
|
||||
if (!CreatedStructure.ContainsKey(tag["index"]))
|
||||
this.CreatedStructure.Add(tag["index"], new Dictionary<string, HashSet<string>>());
|
||||
}
|
||||
else if (
|
||||
!tag.EndTag &&
|
||||
_active &&
|
||||
tag.Name == "line" &&
|
||||
!String.IsNullOrWhiteSpace(tag["index"])
|
||||
)
|
||||
{
|
||||
_line = tag["index"];
|
||||
if (!CreatedStructure[Index][_page].Contains(_line))
|
||||
{
|
||||
CreatedStructure[Index][_page].Add(_line);
|
||||
}
|
||||
}
|
||||
else if (
|
||||
!tag.EndTag &&
|
||||
_active &&
|
||||
tag.Name == "page" &&
|
||||
!String.IsNullOrWhiteSpace(tag["index"])
|
||||
)
|
||||
{
|
||||
_page = tag["index"];
|
||||
if (!CreatedStructure[Index].ContainsKey(_page))
|
||||
CreatedStructure[Index].Add(_page, new HashSet<string>());
|
||||
}
|
||||
else if (
|
||||
_active &&
|
||||
!tag.EndTag &&
|
||||
!tag.IsEmpty &&
|
||||
tag.Name == "hand" &&
|
||||
!String.IsNullOrWhiteSpace(tag["ref"])
|
||||
)
|
||||
{
|
||||
_person = tag["ref"];
|
||||
_handstartln = _line;
|
||||
_handstartpg = _page;
|
||||
}
|
||||
else if (
|
||||
_active &&
|
||||
tag.EndTag &&
|
||||
tag.Name == "hand"
|
||||
)
|
||||
{
|
||||
if (_hands == null)
|
||||
_hands = new List<Hand>();
|
||||
_hands.Add(new Hand(Index, _person, _handstartpg, _handstartln, _page, _line));
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Activate(IReader reader, Tag tag)
|
||||
{
|
||||
if (!_active && reader != null && tag != null)
|
||||
{
|
||||
_active = true;
|
||||
_reader = reader;
|
||||
Index = tag["index"];
|
||||
_element = new ElementStringBinder(reader, tag, Add, _normalizeWhitespace);
|
||||
}
|
||||
}
|
||||
|
||||
private void Add(string text)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(text)) return;
|
||||
var letter = new Letter(
|
||||
Index,
|
||||
text
|
||||
);
|
||||
CreatedInstances.TryAdd(Index, letter);
|
||||
if (_hands != null)
|
||||
{
|
||||
if (!CreatedHands.ContainsKey(Index))
|
||||
CreatedHands.Add(Index, _hands);
|
||||
else
|
||||
CreatedHands[Index].AddRange(_hands);
|
||||
}
|
||||
Reset();
|
||||
}
|
||||
|
||||
protected override void Reset()
|
||||
{
|
||||
Index = "";
|
||||
_active = false;
|
||||
_element = null;
|
||||
_hands = null;
|
||||
}
|
||||
|
||||
protected void Deactivate()
|
||||
{
|
||||
_element.Unsubscribe();
|
||||
Reset();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
56
Archive/HaDocument/Reactors/LocationDefsReactor.cs
Normal file
56
Archive/HaDocument/Reactors/LocationDefsReactor.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
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 LocationDefsReactor : Reactor {
|
||||
internal Dictionary<string, Location> CreatedInstances;
|
||||
|
||||
|
||||
// State
|
||||
private string Index;
|
||||
private string Name;
|
||||
|
||||
internal LocationDefsReactor(IReader reader, IntermediateLibrary lib) : base(reader, lib) {
|
||||
lib.Locations = new Dictionary<string, Location>();
|
||||
CreatedInstances = lib.Locations;
|
||||
reader.Tag += Listen;
|
||||
}
|
||||
|
||||
protected override void Listen(object sender, Tag tag) {
|
||||
if (
|
||||
!tag.EndTag &&
|
||||
tag.IsEmpty &&
|
||||
tag.Name == "locationDef" &&
|
||||
!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"];
|
||||
Add();
|
||||
_active = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Reset() {
|
||||
Index = "";
|
||||
Name = "";
|
||||
}
|
||||
|
||||
protected void Add() {
|
||||
CreatedInstances.Add(Index, new Location(Index, Name));
|
||||
}
|
||||
}
|
||||
}
|
||||
100
Archive/HaDocument/Reactors/MarginalReactor.cs
Normal file
100
Archive/HaDocument/Reactors/MarginalReactor.cs
Normal file
@@ -0,0 +1,100 @@
|
||||
using HaDocument.Models;
|
||||
using System.Collections.Generic;
|
||||
using HaXMLReader.EvArgs;
|
||||
using HaXMLReader.Interfaces;
|
||||
using System;
|
||||
|
||||
namespace HaDocument.Reactors {
|
||||
class MarginalReactor : Reactor {
|
||||
internal Dictionary<string, Marginal> CreatedInstances;
|
||||
internal Dictionary<string, List<Backlink>> CreatedBacklinks;
|
||||
private bool _normalizeWhitespace = false;
|
||||
|
||||
// State
|
||||
private string Index = "";
|
||||
private string Letter = "";
|
||||
private string Page = "";
|
||||
private string Line = "";
|
||||
|
||||
private ElementStringBinder _element = null;
|
||||
|
||||
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>>();
|
||||
CreatedBacklinks = lib.Backlinks;
|
||||
CreatedInstances = lib.Marginals;
|
||||
reader.OpenTag += Listen;
|
||||
}
|
||||
|
||||
protected override void Listen(object sender, Tag tag) {
|
||||
if (
|
||||
!tag.EndTag &&
|
||||
!tag.IsEmpty &&
|
||||
tag.Name == "marginal" &&
|
||||
!String.IsNullOrEmpty(tag["index"]) &&
|
||||
!String.IsNullOrWhiteSpace(tag["letter"]) &&
|
||||
!String.IsNullOrWhiteSpace(tag["page"]) &&
|
||||
!String.IsNullOrWhiteSpace(tag["line"])
|
||||
) {
|
||||
Activate(_reader, tag);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Activate(IReader reader, Tag tag) {
|
||||
if (!_active && reader != null && tag != null) {
|
||||
_active = true;
|
||||
_reader = reader;
|
||||
Index = tag["index"];
|
||||
Letter = tag["letter"];
|
||||
Page = tag["page"];
|
||||
Line = tag["line"];
|
||||
_element = new ElementStringBinder(_reader, tag, Add, _normalizeWhitespace);
|
||||
reader.Tag += OnTag;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTag(object _, Tag tag) {
|
||||
if(
|
||||
!tag.EndTag &&
|
||||
tag.Name =="link"
|
||||
) {
|
||||
var id = "";
|
||||
if (tag.Values.ContainsKey("subref"))
|
||||
id = tag["subref"];
|
||||
else if (tag.Values.ContainsKey("ref"))
|
||||
id = tag["ref"];
|
||||
if (!String.IsNullOrWhiteSpace(id)) {
|
||||
if (!CreatedBacklinks.ContainsKey(id))
|
||||
CreatedBacklinks.Add(id, new List<Backlink>());
|
||||
CreatedBacklinks[id].Add(new Backlink(id, Letter, Page, Line, Index));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Add(string element) {
|
||||
if (String.IsNullOrWhiteSpace(element)) return;
|
||||
var marg = new Marginal(
|
||||
Index,
|
||||
Letter,
|
||||
Page,
|
||||
Line,
|
||||
element
|
||||
);
|
||||
CreatedInstances.TryAdd(Index, marg);
|
||||
Reset();
|
||||
}
|
||||
|
||||
protected override void Reset() {
|
||||
Index = "";
|
||||
_active = false;
|
||||
_element = null;
|
||||
_reader.Tag -= OnTag;
|
||||
}
|
||||
|
||||
public void Deactivate() {
|
||||
_element.Unsubscribe();
|
||||
Reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
196
Archive/HaDocument/Reactors/MetaReactor.cs
Normal file
196
Archive/HaDocument/Reactors/MetaReactor.cs
Normal file
@@ -0,0 +1,196 @@
|
||||
using System;
|
||||
using HaXMLReader.EvArgs;
|
||||
using HaXMLReader.Interfaces;
|
||||
using HaDocument.Models;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace HaDocument.Reactors {
|
||||
class MetaReactor : Reactor {
|
||||
|
||||
internal Dictionary<string, Meta> CreatedInstances { get; }
|
||||
|
||||
private string[] _availableVolumes;
|
||||
private (int, int) _availableYearRange;
|
||||
|
||||
// State
|
||||
private string Index { get; set; } = "";
|
||||
private string Autopsic { get; set; } = "";
|
||||
private string Volume { get; set; } = "";
|
||||
private string Page { get; set; } = "";
|
||||
private string Date { get; set; } = "";
|
||||
private DateTime Sort { get; set; } = new DateTime(1700, 1, 1);
|
||||
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 dateChanged {get; set; } = false;
|
||||
private string Location { get; set; } = "";
|
||||
private List<string> Senders { get; set; } = null;
|
||||
private List<string> Receivers { get; set; } = null;
|
||||
|
||||
internal MetaReactor(IReader reader, IntermediateLibrary lib, string[] availableVolumes, (int, int) availableYearRange) : base(reader, lib) {
|
||||
_availableVolumes = availableVolumes;
|
||||
_availableYearRange = availableYearRange;
|
||||
lib.Metas = new Dictionary<string, Meta>();
|
||||
CreatedInstances = lib.Metas;
|
||||
reader.OpenTag += Listen;
|
||||
}
|
||||
|
||||
protected override void Listen(object sender, Tag tag) {
|
||||
if (
|
||||
!tag.EndTag &&
|
||||
!tag.IsEmpty &&
|
||||
tag.Name =="letterDesc" &&
|
||||
!String.IsNullOrWhiteSpace(tag["ref"])
|
||||
) {
|
||||
Activate(_reader, tag);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Activate(IReader reader, Tag tag) {
|
||||
if (!_active && reader != null && tag != null) {
|
||||
Reset();
|
||||
_active = true;
|
||||
Index = tag["ref"];
|
||||
reader.Tag += OnTag;
|
||||
_reader = reader;
|
||||
}
|
||||
}
|
||||
|
||||
public void Deactivate() {
|
||||
if (_active) {
|
||||
Abort();
|
||||
Add();
|
||||
}
|
||||
}
|
||||
|
||||
public void Abort() {
|
||||
if (_active) {
|
||||
_active = false;
|
||||
_reader.Tag -= OnTag;
|
||||
}
|
||||
}
|
||||
|
||||
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"];
|
||||
break;
|
||||
case "date":
|
||||
Date = tag["value"];
|
||||
break;
|
||||
case "location":
|
||||
Location = tag["ref"];
|
||||
break;
|
||||
case "sender":
|
||||
if (!String.IsNullOrWhiteSpace(tag["ref"])) Senders.Add(tag["ref"]);
|
||||
break;
|
||||
case "receiver":
|
||||
if (!String.IsNullOrWhiteSpace(tag["ref"])) Receivers.Add(tag["ref"]);
|
||||
break;
|
||||
case "sort":
|
||||
DateTime res;
|
||||
System.DateTime.TryParse(tag["value"], out res);
|
||||
Sort = res;
|
||||
int res2 = 0;
|
||||
Int32.TryParse(tag["order"], out res2);
|
||||
Order = res2;
|
||||
break;
|
||||
case "hasOriginal":
|
||||
var val = tag["value"];
|
||||
if (val.ToLower() == "true")
|
||||
hasOriginal = OptionalBool.True;
|
||||
else if (val.ToLower() == "false")
|
||||
hasOriginal = OptionalBool.False;
|
||||
else
|
||||
hasOriginal = OptionalBool.None;
|
||||
break;
|
||||
case "isProofread":
|
||||
var val2 = tag["value"];
|
||||
if (val2.ToLower() == "true")
|
||||
isProofread = OptionalBool.True;
|
||||
else if (val2.ToLower() == "false")
|
||||
isProofread = OptionalBool.False;
|
||||
else
|
||||
isProofread = OptionalBool.None;
|
||||
break;
|
||||
case "isDraft":
|
||||
var val3 = tag["value"];
|
||||
if (val3.ToLower() == "true")
|
||||
isDraft = OptionalBool.True;
|
||||
else if (val3.ToLower() == "false")
|
||||
isDraft = OptionalBool.False;
|
||||
else
|
||||
isDraft = OptionalBool.None;
|
||||
break;
|
||||
case "ZHInfo":
|
||||
if (!tag.EndTag) {
|
||||
inZH = tag["inzh"] == "false" ? false : true;
|
||||
}
|
||||
break;
|
||||
case "dateChanged":
|
||||
dateChanged = tag["value"].ToLower() == "true" ? true : false;
|
||||
break;
|
||||
case "alternativeLineNumbering":
|
||||
AltLineNumbering = tag["value"].ToLower() == "true" ? true : false;
|
||||
break;
|
||||
case "letterDesc":
|
||||
if (tag.EndTag) Deactivate();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void Add() {
|
||||
if (
|
||||
_availableVolumes.Contains(Volume) ||
|
||||
(Sort.Year >= _availableYearRange.Item1 && Sort.Year <= _availableYearRange.Item2) ||
|
||||
(_availableVolumes == null && _availableYearRange.Item1 == 0 && _availableYearRange.Item2 == 0)
|
||||
) {
|
||||
var ZHInfo = !inZH ? null : new ZHInfo(AltLineNumbering, dateChanged, Volume, Page);
|
||||
var meta = new Meta(
|
||||
Index,
|
||||
Autopsic,
|
||||
Date,
|
||||
Sort,
|
||||
Order,
|
||||
hasOriginal,
|
||||
isProofread,
|
||||
isDraft,
|
||||
Location,
|
||||
Senders,
|
||||
Receivers,
|
||||
ZHInfo
|
||||
);
|
||||
CreatedInstances.TryAdd(meta.Index, meta);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Reset() {
|
||||
inZH = true;
|
||||
hasOriginal = OptionalBool.None;
|
||||
isProofread = OptionalBool.None;
|
||||
isDraft = OptionalBool.None;
|
||||
dateChanged = false;
|
||||
Index = "";
|
||||
Autopsic = "";
|
||||
Volume = "";
|
||||
Page = "";
|
||||
Date = "";
|
||||
DateTime Sort = new DateTime(1700, 1, 1);
|
||||
Order = -1;
|
||||
AltLineNumbering = false;
|
||||
Location = "";
|
||||
Senders = new List<string>();
|
||||
Receivers = new List<string>();
|
||||
}
|
||||
}
|
||||
}
|
||||
60
Archive/HaDocument/Reactors/PersonDefsReactor.cs
Normal file
60
Archive/HaDocument/Reactors/PersonDefsReactor.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 PersonDefsReactor : Reactor {
|
||||
internal Dictionary<string, Person> CreatedInstances;
|
||||
|
||||
// State
|
||||
private string Index;
|
||||
private string Name;
|
||||
private string Prename = "";
|
||||
private string Surname = "";
|
||||
|
||||
internal PersonDefsReactor(IReader reader, IntermediateLibrary lib) : base(reader, lib) {
|
||||
lib.Persons = new Dictionary<string, Person>();
|
||||
CreatedInstances = lib.Persons;
|
||||
reader.Tag += Listen;
|
||||
}
|
||||
|
||||
protected override void Listen(object sender, Tag tag) {
|
||||
if (!tag.EndTag &&
|
||||
tag.IsEmpty &&
|
||||
tag.Name == "personDef" &&
|
||||
!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"];
|
||||
Prename = tag["vorname"];
|
||||
Surname = tag["nachname"];
|
||||
Add();
|
||||
_active = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Reset() {
|
||||
Index = "";
|
||||
Name = "";
|
||||
Prename = "";
|
||||
Surname = "";
|
||||
}
|
||||
|
||||
public void Add() {
|
||||
CreatedInstances.Add(Index, new Person(Index, Name, Prename, Surname));
|
||||
}
|
||||
}
|
||||
}
|
||||
20
Archive/HaDocument/Reactors/Reactor.cs
Normal file
20
Archive/HaDocument/Reactors/Reactor.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using HaDocument.Models;
|
||||
using HaXMLReader.Interfaces;
|
||||
using HaXMLReader.EvArgs;
|
||||
|
||||
namespace HaDocument.Reactors {
|
||||
abstract class Reactor {
|
||||
protected IReader _reader;
|
||||
protected IntermediateLibrary _lib;
|
||||
protected bool _active = false;
|
||||
|
||||
internal Reactor(IReader reader, IntermediateLibrary lib) {
|
||||
_reader = reader;
|
||||
_lib = lib;
|
||||
}
|
||||
|
||||
protected abstract void Listen(object sender, Tag tag);
|
||||
protected abstract void Activate(IReader reader, Tag tag);
|
||||
protected abstract void Reset();
|
||||
}
|
||||
}
|
||||
156
Archive/HaDocument/Reactors/TraditionsReactor.cs
Normal file
156
Archive/HaDocument/Reactors/TraditionsReactor.cs
Normal file
@@ -0,0 +1,156 @@
|
||||
using HaDocument.Models;
|
||||
using System.Collections.Generic;
|
||||
using HaXMLReader.EvArgs;
|
||||
using HaXMLReader.Interfaces;
|
||||
using System;
|
||||
|
||||
namespace HaDocument.Reactors
|
||||
{
|
||||
class TraditionsReactor : Reactor
|
||||
{
|
||||
internal Dictionary<string, Tradition> CreatedInstances;
|
||||
internal Dictionary<string, Dictionary<string, HashSet<string>>> CreatedStructure;
|
||||
internal Dictionary<string, List<Hand>> CreatedHands;
|
||||
private bool _normalizeWhitespace = false;
|
||||
|
||||
// State
|
||||
private string Index = "";
|
||||
|
||||
private string _page = "";
|
||||
private string _line = "";
|
||||
|
||||
|
||||
private List<Hand> _hands;
|
||||
private string _person = "";
|
||||
private string _handstartpg = "";
|
||||
private string _handstartln = "";
|
||||
|
||||
private ElementStringBinder _element = null;
|
||||
|
||||
internal TraditionsReactor(IReader reader, IntermediateLibrary lib, bool normalizeWhitespace) : base(reader, lib)
|
||||
{
|
||||
_normalizeWhitespace = normalizeWhitespace;
|
||||
_lib.Traditions = new Dictionary<string, Tradition>();
|
||||
if (lib.LetterPageLines == null)
|
||||
lib.LetterPageLines = new Dictionary<string, Dictionary<string, HashSet<string>>>();
|
||||
if (lib.Hands == null)
|
||||
lib.Hands = new Dictionary<string, List<Hand>>();
|
||||
CreatedHands = lib.Hands;
|
||||
CreatedInstances = _lib.Traditions;
|
||||
CreatedStructure = lib.LetterPageLines;
|
||||
reader.Tag += Listen;
|
||||
}
|
||||
|
||||
protected override void Listen(object sender, Tag tag)
|
||||
{
|
||||
if (!tag.EndTag &&
|
||||
!tag.IsEmpty &&
|
||||
tag.Name == "letterTradition" &&
|
||||
!String.IsNullOrWhiteSpace(tag["ref"])
|
||||
)
|
||||
{
|
||||
Activate(_reader, tag);
|
||||
}
|
||||
else if (
|
||||
!tag.EndTag &&
|
||||
_active &&
|
||||
tag.Name == "ZHText"
|
||||
)
|
||||
{
|
||||
if (!CreatedStructure.ContainsKey(tag["index"]))
|
||||
this.CreatedStructure.Add(tag["index"], new Dictionary<string, HashSet<string>>());
|
||||
}
|
||||
else if (
|
||||
!tag.EndTag &&
|
||||
_active &&
|
||||
tag.Name == "line" &&
|
||||
!String.IsNullOrWhiteSpace(tag["index"])
|
||||
)
|
||||
{
|
||||
_line = tag["index"];
|
||||
if (!CreatedStructure[Index][_page].Contains(_line))
|
||||
{
|
||||
CreatedStructure[Index][_page].Add(_line);
|
||||
}
|
||||
}
|
||||
else if (
|
||||
!tag.EndTag &&
|
||||
_active &&
|
||||
tag.Name == "page" &&
|
||||
!String.IsNullOrWhiteSpace(tag["index"])
|
||||
)
|
||||
{
|
||||
_page = tag["index"];
|
||||
if (!CreatedStructure[Index].ContainsKey(_page))
|
||||
{
|
||||
CreatedStructure[Index].Add(_page, new HashSet<string>());
|
||||
}
|
||||
}
|
||||
else if (
|
||||
_active &&
|
||||
!tag.EndTag &&
|
||||
!tag.IsEmpty &&
|
||||
tag.Name == "hand" &&
|
||||
!String.IsNullOrWhiteSpace(tag["ref"])
|
||||
)
|
||||
{
|
||||
_person = tag["ref"];
|
||||
_handstartln = _line;
|
||||
_handstartpg = _page;
|
||||
}
|
||||
else if (
|
||||
_active &&
|
||||
tag.EndTag &&
|
||||
tag.Name == "hand"
|
||||
)
|
||||
{
|
||||
if (_hands == null)
|
||||
_hands = new List<Hand>();
|
||||
_hands.Add(new Hand(Index, _person, _handstartpg, _handstartln, _page, _line));
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Activate(IReader reader, Tag tag)
|
||||
{
|
||||
if (!_active && reader != null && tag != null)
|
||||
{
|
||||
_active = true;
|
||||
Index = tag["ref"];
|
||||
_element = new ElementStringBinder(reader, tag, Add, _normalizeWhitespace);
|
||||
}
|
||||
}
|
||||
|
||||
private void Add(string element)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(element)) return;
|
||||
var reason = new Tradition(
|
||||
Index,
|
||||
element);
|
||||
CreatedInstances.TryAdd(Index, reason);
|
||||
if (_hands != null)
|
||||
{
|
||||
if (!CreatedHands.ContainsKey(Index))
|
||||
CreatedHands.Add(Index, _hands);
|
||||
else
|
||||
CreatedHands[Index].AddRange(_hands);
|
||||
}
|
||||
Reset();
|
||||
}
|
||||
|
||||
protected override void Reset()
|
||||
{
|
||||
Index = "";
|
||||
_page = "";
|
||||
_line = "";
|
||||
_active = false;
|
||||
_element = null;
|
||||
_hands = null;
|
||||
}
|
||||
|
||||
protected void Deactivate()
|
||||
{
|
||||
_element.Unsubscribe();
|
||||
Reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user