CMIF implementiert

This commit is contained in:
Simon Martens
2024-11-18 17:25:09 +01:00
parent 822cad09de
commit 6f2a276772
9 changed files with 419 additions and 31 deletions

View File

@@ -8,6 +8,7 @@ namespace HaDocument.Models {
public string? Surname { get; }
public string? Komm { get; }
public string? Reference { get; }
public bool IsOrg { get; } = false;
public XElement? XElement { get; }
public Person(
@@ -17,7 +18,8 @@ namespace HaDocument.Models {
string? surname,
string? komm,
string? reference,
XElement? xElement = null
XElement? xElement = null,
bool IsOrg = false
) {
Index = index;
Name = name;
@@ -25,11 +27,14 @@ namespace HaDocument.Models {
Surname = surname;
Komm = komm;
Reference = reference;
this.XElement = xElement;
this.IsOrg = IsOrg;
}
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;
var org = element.HasAttributes && element.Attribute("org")?.Value == "true";
return new Person(
element.Attribute("index")!.Value,
element.Attribute("name")!.Value,
@@ -37,8 +42,9 @@ namespace HaDocument.Models {
element.Attribute("nachname")?.Value,
element.Attribute("komm")?.Value,
element.Attribute("ref")?.Value,
element
element,
org
);
}
}
}
}