Initial replacement of old repository.

This commit is contained in:
Simon Martens
2021-09-15 13:31:10 +02:00
commit 3125edf027
222 changed files with 582725 additions and 0 deletions

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