From 995a886e94577c95dd0f2f22ec513f17391c9301 Mon Sep 17 00:00:00 2001
From: Markus Quaritsch <markus.quaritsch@tugraz.at>
Date: Thu, 7 Jul 2022 11:05:32 +0200
Subject: [PATCH] bugfix writing interim step input xml (correcting namespace)
 bugfix reading gui-attribute

---
 VECTO3GUI2020/Helper/Converter/EnumConverter.cs  |  2 +-
 .../ComponentWriter/XMLBusAuxiliariesWriter.cs   |  4 ++--
 .../ComponentWriter/XMLVehicleWriter.cs          |  2 +-
 VECTO3GUI2020/Util/XML/XMLNamespaces.cs          | 16 +++++++---------
 .../Implementation/StageViewModelBase.cs         |  4 ++--
 .../ComponentWriterNinjectModule.cs              |  2 +-
 .../GroupWriter/XMLGroupWriterNinjectModule.cs   |  2 +-
 .../OutputData/XML/XMLDeclarationNamespaces.cs   |  1 +
 8 files changed, 16 insertions(+), 17 deletions(-)

diff --git a/VECTO3GUI2020/Helper/Converter/EnumConverter.cs b/VECTO3GUI2020/Helper/Converter/EnumConverter.cs
index 12dffc1f3c..55f045ea57 100644
--- a/VECTO3GUI2020/Helper/Converter/EnumConverter.cs
+++ b/VECTO3GUI2020/Helper/Converter/EnumConverter.cs
@@ -22,7 +22,7 @@ namespace VECTO3GUI2020.Helper.Converter
 			var attributes =
 				valueType.GetField(value.ToString())?.GetCustomAttributes( typeof(GuiLabelAttribute),false);
 
-			if (!(attributes?.First() is GuiLabelAttribute attribute)) {
+			if (!(attributes?.FirstOrDefault() is GuiLabelAttribute attribute)) {
 				return value;
 			} else {
 				return attribute.Label;
diff --git a/VECTO3GUI2020/Util/XML/Implementation/ComponentWriter/XMLBusAuxiliariesWriter.cs b/VECTO3GUI2020/Util/XML/Implementation/ComponentWriter/XMLBusAuxiliariesWriter.cs
index 57b1a4ba9b..7c53ed93ce 100644
--- a/VECTO3GUI2020/Util/XML/Implementation/ComponentWriter/XMLBusAuxiliariesWriter.cs
+++ b/VECTO3GUI2020/Util/XML/Implementation/ComponentWriter/XMLBusAuxiliariesWriter.cs
@@ -64,7 +64,7 @@ namespace VECTO3GUI2020.Util.XML.Implementation.ComponentWriter
 
 		public override void Initialize()
 		{
-			_defaultNamespace = XMLNamespaces.v2_10_2; 
+			_defaultNamespace = XMLNamespaces.V24; 
 			_xElement = new XElement(_defaultNamespace + XMLNames.Component_Auxiliaries);
 		}
 
@@ -127,7 +127,7 @@ namespace VECTO3GUI2020.Util.XML.Implementation.ComponentWriter
 		{
 
 			var dataElement = new XElement(_defaultNamespace + XMLNames.ComponentDataWrapper,
-				new XAttribute("xmlns" , XMLNamespaces.v2_10_2),
+				new XAttribute("xmlns" , XMLNamespaces.V24),
 				new XAttribute(XMLNamespaces.Xsi + XMLNames.Attr_Type, "AUX_Conventional_CompletedBusType"));
 
 			if (_inputData.ElectricConsumers != null) {
diff --git a/VECTO3GUI2020/Util/XML/Implementation/ComponentWriter/XMLVehicleWriter.cs b/VECTO3GUI2020/Util/XML/Implementation/ComponentWriter/XMLVehicleWriter.cs
index 43fd5a161c..d81f3a11e1 100644
--- a/VECTO3GUI2020/Util/XML/Implementation/ComponentWriter/XMLVehicleWriter.cs
+++ b/VECTO3GUI2020/Util/XML/Implementation/ComponentWriter/XMLVehicleWriter.cs
@@ -221,7 +221,7 @@ namespace VECTO3GUI2020.Util.XML.Implementation.ComponentWriter
 
 		protected override void Initialize()
 		{
-			_defaultNamespace = XMLNamespaces.v2_10_2;
+			_defaultNamespace = XMLNamespaces.V24;
 
 			_Xelement = new XElement(XMLNamespaces.V20 + XMLNames.Component_Vehicle, 
 				new XAttribute("xmlns",  _defaultNamespace));
diff --git a/VECTO3GUI2020/Util/XML/XMLNamespaces.cs b/VECTO3GUI2020/Util/XML/XMLNamespaces.cs
index c0053b0d80..dc88a706c7 100644
--- a/VECTO3GUI2020/Util/XML/XMLNamespaces.cs
+++ b/VECTO3GUI2020/Util/XML/XMLNamespaces.cs
@@ -9,14 +9,15 @@ namespace VECTO3GUI2020.Util.XML
 		public static XNamespace Xsi = XNamespace.Get("http://www.w3.org/2001/XMLSchema-instance");
 		public static XNamespace Tns = "urn:tugraz:ivt:VectoAPI:DeclarationInput";
 		public static XNamespace Tns_v20 = Tns.NamespaceName + ":v2.0";
-		public static XNamespace V26 = DeclarationDefinition + ":DEV:v2.6";
+		//public static XNamespace V26 = DeclarationDefinition + ":DEV:v2.6";
 		public static XNamespace V21 = DeclarationDefinition + ":v2.1";
-		public static XNamespace V23 = DeclarationDefinition + ":DEV:v2.3";
+		public static XNamespace V23 = DeclarationDefinition + ":v2.3";
+		public static XNamespace V24 = DeclarationDefinition + ":v2.4";
 		public static XNamespace V20 = DeclarationDefinition + ":v2.0";
 		public static XNamespace V10 = DeclarationDefinition + ":v1.0";
-		public static XNamespace V28 = DeclarationDefinition + ":DEV:v2.8";
-		public static XNamespace v2_10_1 = DeclarationDefinition + ":DEV:v2.10.1";
-		public static XNamespace v2_10_2 = DeclarationDefinition + ":DEV:v2.10.2";
+		//public static XNamespace V28 = DeclarationDefinition + ":DEV:v2.8";
+		//public static XNamespace v2_10_1 = DeclarationDefinition + ":DEV:v2.10.1";
+		//public static XNamespace v2_10_2 = DeclarationDefinition + ":DEV:v2.10.2";
 		public static XNamespace Di = "http://www.w3.org/2000/09/xmldsig#";
 
 
@@ -33,11 +34,8 @@ namespace VECTO3GUI2020.Util.XML
 				{ V20, "v2.0"},
 				{ V21, "v2.1"},
 				{ V23, "v2.3"},
-				{ V26, "v2.6"},
+				{ V24, "v2.4"},
 				{ Di, "di"},
-				{ V28, "v2.8"},
-				{v2_10_2, "v2.10.2"},
-				{v2_10_1, "v2.10.1"}
 			};
 
 		public static string GetPrefix(XNamespace xNamespace)
diff --git a/VECTO3GUI2020/ViewModel/MultiStage/Implementation/StageViewModelBase.cs b/VECTO3GUI2020/ViewModel/MultiStage/Implementation/StageViewModelBase.cs
index 137647f0f4..250f3ae508 100644
--- a/VECTO3GUI2020/ViewModel/MultiStage/Implementation/StageViewModelBase.cs
+++ b/VECTO3GUI2020/ViewModel/MultiStage/Implementation/StageViewModelBase.cs
@@ -183,8 +183,8 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation
 
 
 			var xElement = vehicleWriter.GetElement();
-			var xDoc = xElement.CreateWrapperDocument(XMLNamespaces.v2_10_2);
-			Debug.WriteLine(xElement.CreateWrapperDocument(XMLNamespaces.v2_10_2).ToString());
+			var xDoc = xElement.CreateWrapperDocument(XMLNamespaces.V24);
+			Debug.WriteLine(xElement.CreateWrapperDocument(XMLNamespaces.V24).ToString());
 
 
 			var valid = false;
diff --git a/VectoCore/VectoCore/OutputData/XML/ComponentWriter/ComponentWriterNinjectModule.cs b/VectoCore/VectoCore/OutputData/XML/ComponentWriter/ComponentWriterNinjectModule.cs
index 3f3db79d76..015197523b 100644
--- a/VectoCore/VectoCore/OutputData/XML/ComponentWriter/ComponentWriterNinjectModule.cs
+++ b/VectoCore/VectoCore/OutputData/XML/ComponentWriter/ComponentWriterNinjectModule.cs
@@ -20,7 +20,7 @@ namespace TUGraz.VectoCore.OutputData.XML.ComponentWriter
 
 
 			//ADASTypes
-			var v2102 = XMLDeclarationNamespaces.v2_10_2;
+			var v2102 = XMLDeclarationNamespaces.V24;
 			Bind<IDeclarationAdasWriter>().To<AdasConventionalWriter>().
 				Named(GetName(GroupNames.ADAS_Conventional_Type, v2102));
 
diff --git a/VectoCore/VectoCore/OutputData/XML/GroupWriter/XMLGroupWriterNinjectModule.cs b/VectoCore/VectoCore/OutputData/XML/GroupWriter/XMLGroupWriterNinjectModule.cs
index 8b46e43aa2..084c13b344 100644
--- a/VectoCore/VectoCore/OutputData/XML/GroupWriter/XMLGroupWriterNinjectModule.cs
+++ b/VectoCore/VectoCore/OutputData/XML/GroupWriter/XMLGroupWriterNinjectModule.cs
@@ -22,7 +22,7 @@ namespace TUGraz.VectoCore.OutputData.XML.GroupWriter
 			Bind<IGroupWriterFactory>().ToFactory(() => new UseFirstTwoArgumentsAsInstanceProvider(1, false)).InSingletonScope();
 
 			///Vehicle V2_10_2
-			var v2102 = XMLDeclarationNamespaces.v2_10_2;
+			var v2102 = XMLDeclarationNamespaces.V24;
 			Bind<IVehicleDeclarationGroupWriter>().To<CompletedBusGeneralParametersWriterV2_10_2>().InSingletonScope().
 				Named(GetName(GroupNames.Vehicle_CompletedBus_GeneralParametersSequenceGroup, v2102));
 			Bind<IVehicleDeclarationGroupWriter>().To<CompletedBusParametersWriterV2_10_2>().InSingletonScope().
diff --git a/VectoCore/VectoCore/OutputData/XML/XMLDeclarationNamespaces.cs b/VectoCore/VectoCore/OutputData/XML/XMLDeclarationNamespaces.cs
index fb74d2980b..47ab2e5bb4 100644
--- a/VectoCore/VectoCore/OutputData/XML/XMLDeclarationNamespaces.cs
+++ b/VectoCore/VectoCore/OutputData/XML/XMLDeclarationNamespaces.cs
@@ -16,6 +16,7 @@ namespace TUGraz.VectoCore.OutputData.XML
 		public static readonly XNamespace V26 = DeclarationDefinition + ":DEV:v2.6";
 		public static readonly XNamespace V21 = DeclarationDefinition + ":v2.1";
 		public static readonly XNamespace V23 = DeclarationDefinition + ":DEV:v2.3";
+		public static readonly XNamespace V24 = DeclarationDefinition + ":v2.4";
 		public static readonly XNamespace V20 = DeclarationDefinition + ":v2.0";
 		public static readonly XNamespace V10 = DeclarationDefinition + ":v1.0";
 		public static readonly XNamespace V28 = DeclarationDefinition + ":DEV:v2.8";
-- 
GitLab