mirror of
https://github.com/Theodor-Springmann-Stiftung/hamann-ausgabe-core.git
synced 2025-10-30 17:55:32 +00:00
Results of SyntaxCheck -> extra State
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
namespace HaWeb.XMLTests;
|
||||
|
||||
using HaWeb.Models;
|
||||
using HaWeb.XMLParser;
|
||||
|
||||
public class XMLTestService : IXMLTestService {
|
||||
@@ -7,28 +9,26 @@ public class XMLTestService : IXMLTestService {
|
||||
public XMLTestService() {
|
||||
var roottypes = _GetAllTypesThatImplementInterface<INodeRule>().ToList();
|
||||
roottypes.ForEach( x => {
|
||||
if (this.Ruleset == null) this.Ruleset = new Dictionary<string, INodeRule>();
|
||||
if (this.Ruleset == null) this.Ruleset = new();
|
||||
var instance = (INodeRule)Activator.CreateInstance(x)!;
|
||||
if (instance != null) this.Ruleset.Add(instance.Name, instance);
|
||||
});
|
||||
|
||||
var collectionruleset = _GetAllTypesThatImplementInterface<ICollectionRule>().ToList();
|
||||
collectionruleset.ForEach( x => {
|
||||
if (this.CollectionRuleset == null) this.CollectionRuleset = new Dictionary<string, ICollectionRule>();
|
||||
if (this.CollectionRuleset == null) this.CollectionRuleset = new();
|
||||
var instance = (ICollectionRule)Activator.CreateInstance(x)!;
|
||||
if (instance != null) this.CollectionRuleset.Add(instance.Name, instance);
|
||||
});
|
||||
}
|
||||
|
||||
public void Test(IXMLInteractionService _XMLService) {
|
||||
var docs = _XMLService.GetLoaded();
|
||||
if (docs == null) return;
|
||||
var tester = new XMLTester(this, docs);
|
||||
tester.Test();
|
||||
public Dictionary<string, SyntaxCheckModel>? Test(Dictionary<string, FileList?>? _Loaded, Dictionary<string, SyntaxCheckModel> _Results) {
|
||||
if (_Loaded == null) return null;
|
||||
var tester = new XMLTester(this, _Loaded, _Results);
|
||||
return tester.Test();
|
||||
}
|
||||
|
||||
private IEnumerable<Type> _GetAllTypesThatImplementInterface<T>()
|
||||
{
|
||||
private IEnumerable<Type> _GetAllTypesThatImplementInterface<T>() {
|
||||
return System.Reflection.Assembly.GetExecutingAssembly()
|
||||
.GetTypes()
|
||||
.Where(type => typeof(T).IsAssignableFrom(type) && !type.IsInterface);
|
||||
|
||||
Reference in New Issue
Block a user