Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 6f8e36ee authored by Harald MARTINI's avatar Harald MARTINI
Browse files

added GetComponent Method to AbstractComponentReader

parent 045065db
No related branches found
No related tags found
No related merge requests found
......@@ -50,12 +50,19 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl
ParentComponent = parent;
}
protected virtual T CreateComponent<T>(
string component, Func<string, XmlNode, string, T> componentCreator, bool createDummy = false)
protected virtual XmlNode GetComponentNode(string component)
{
var componentNode = BaseNode.LocalName == component
? BaseNode
: BaseNode.SelectSingleNode(XMLHelper.QueryLocalName(component));
return componentNode;
}
protected virtual T CreateComponent<T>(
string component, Func<string, XmlNode, string, T> componentCreator, bool createDummy = false)
{
var componentNode = GetComponentNode(component);
var dataNode =
componentNode?.SelectSingleNode($"./*[local-name()='{XMLNames.ComponentDataWrapper}']");
if (componentNode != null) {
......@@ -67,6 +74,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl
return componentCreator(version, componentNode, ParentComponent.DataSource.SourceFile);
}
if (createDummy) {
try {
return componentCreator(null, null, null);
......@@ -75,6 +84,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl
}
}
throw new VectoException("Component {0} not found!", component);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment