From 6cd94de0fa480842c5b31cf61819362ea1c64d1b Mon Sep 17 00:00:00 2001
From: "VKMTHD\\haraldmartini" <harald.martini@student.tugraz.at>
Date: Fri, 2 Sep 2022 12:40:45 +0200
Subject: [PATCH] added possibility to set nameCombinationMethod per
 MethodInfo, updated VehicleTypeAndArchitectureStringHelpers

---
 .../Reader/VectoRunDataFactoryFactory.cs      |  21 ++-
 .../VectoRunDataFactoryNinjectModule.cs       |  43 ++++--
 .../VectoCore/Ninject/VectoNinjectModule.cs   |  10 +-
 .../CIFNinjectModule.cs                       |  13 +-
 .../MRFNinjectModule.cs                       |  13 +-
 .../VIFNinjectModule.cs                       |  30 +++-
 ...CombineArgumentsToNameInstanceProviders.cs |  66 ++++++---
 .../VehicleTypeAndArchitectureStringHelper.cs | 139 +++++++++---------
 8 files changed, 209 insertions(+), 126 deletions(-)

diff --git a/VectoCore/VectoCore/InputData/Reader/VectoRunDataFactoryFactory.cs b/VectoCore/VectoCore/InputData/Reader/VectoRunDataFactoryFactory.cs
index ccab1688dd..85bba6467b 100644
--- a/VectoCore/VectoCore/InputData/Reader/VectoRunDataFactoryFactory.cs
+++ b/VectoCore/VectoCore/InputData/Reader/VectoRunDataFactoryFactory.cs
@@ -20,6 +20,11 @@ namespace TUGraz.VectoCore.InputData.Reader
 			ArchitectureID archId, bool exempted, bool iepc, bool ihpc);
 		IVectoRunDataFactory CreateDeclarationRunDataFactory(VehicleCategory vehicleType, VectoSimulationJobType jobType,
 			ArchitectureID archId, bool exempted, bool iepc, bool ihpc);
+
+		IVectoRunDataFactory CreateDeclarationRunDataFactory(VehicleTypeAndArchitectureStringHelperRundata.VehicleClassification vehicleClassification,
+			IDeclarationInputDataProvider dataProvider,
+			IDeclarationReport report);
+
 	}
 
 
@@ -86,13 +91,15 @@ namespace TUGraz.VectoCore.InputData.Reader
 			//TODO: encapsulate arguments into object
 			var vehicle = declDataProvider.JobInputData.Vehicle;
 			try {
-				
-				var ihpc = (vehicle.Components?.ElectricMachines?.Entries)?.Count(electric => electric.ElectricMachine.IHPCType != "None")  > 0;
-				var iepc = (vehicle.Components?.IEPC != null);
-				return _internalFactory.CreateDeclarationRunDataFactory(declDataProvider.JobInputData.Vehicle.VehicleCategory, 
-					declDataProvider.JobInputData.JobType,
-					declDataProvider.JobInputData.Vehicle.ArchitectureID,
-					declDataProvider.JobInputData.Vehicle.ExemptedVehicle, iepc, ihpc);
+				return _internalFactory.CreateDeclarationRunDataFactory(
+					new VehicleTypeAndArchitectureStringHelperRundata.VehicleClassification(vehicle), declDataProvider,
+					report);
+				//var ihpc = (vehicle.Components?.ElectricMachines?.Entries)?.Count(electric => electric.ElectricMachine.IHPCType != "None")  > 0;
+				//var iepc = (vehicle.Components?.IEPC != null);
+				//return _internalFactory.CreateDeclarationRunDataFactory(declDataProvider.JobInputData.Vehicle.VehicleCategory, 
+				//	declDataProvider.JobInputData.JobType,
+				//	declDataProvider.JobInputData.Vehicle.ArchitectureID,
+				//	declDataProvider.JobInputData.Vehicle.ExemptedVehicle, iepc, ihpc, declDataProvider, report);
 			} catch (Exception ex) {
 				throw new Exception(
 					$"Could not create RunDataFactory for Vehicle Category{declDataProvider.JobInputData.Vehicle.VehicleCategory} {declDataProvider.JobInputData.Vehicle.ArchitectureID}", ex);
diff --git a/VectoCore/VectoCore/InputData/Reader/VectoRunDataFactoryNinjectModule.cs b/VectoCore/VectoCore/InputData/Reader/VectoRunDataFactoryNinjectModule.cs
index 907c6f7db2..730ef21626 100644
--- a/VectoCore/VectoCore/InputData/Reader/VectoRunDataFactoryNinjectModule.cs
+++ b/VectoCore/VectoCore/InputData/Reader/VectoRunDataFactoryNinjectModule.cs
@@ -8,6 +8,7 @@ using Ninject.Modules;
 using TUGraz.VectoCommon.InputData;
 using TUGraz.VectoCommon.Models;
 using TUGraz.VectoCore.InputData.Reader.Impl;
+using TUGraz.VectoCore.OutputData;
 using TUGraz.VectoCore.Utils.Ninject;
 
 namespace TUGraz.VectoCore.InputData.Reader
@@ -15,7 +16,8 @@ namespace TUGraz.VectoCore.InputData.Reader
 	public class VectoRunDataFactoryNinjectModule : AbstractNinjectModule
 	{
 
-		private IVehicleTypeAndArchitectureStringHelper _vehicleStringHelper = new VehicleTypeAndArchitectureStringHelperRundata();
+		private VehicleTypeAndArchitectureStringHelperRundata _vehicleStringHelper = new VehicleTypeAndArchitectureStringHelperRundata();
+
 
 		#region Overrides of NinjectModule
 
@@ -26,17 +28,34 @@ namespace TUGraz.VectoCore.InputData.Reader
 
 			Bind<IInternalRunDataFactoryFactory>().ToFactory(
 					() => new CombineArgumentsToNameInstanceProvider(
-										_vehicleStringHelper.CreateName,
-										6, 6,
-										typeof(IInternalRunDataFactoryFactory)
-											.GetMethod(nameof(IInternalRunDataFactoryFactory
-											.CreateDeclarationRunDataFactory)), 
-										typeof(IInternalRunDataFactoryFactory)
-											.GetMethod(nameof(IInternalRunDataFactoryFactory
-											.CreateDeclarationCompletedBusRunDataFactory))
-										)
-				)
-				.InSingletonScope();
+							new CombineArgumentsToNameInstanceProvider.MethodSettings() {
+								combineToNameDelegate = _vehicleStringHelper.CreateName,
+								methods = new [] {
+									typeof(IInternalRunDataFactoryFactory)
+										.GetMethod(nameof(IInternalRunDataFactoryFactory
+											.CreateDeclarationRunDataFactory),
+											new []
+											{
+												typeof(VehicleTypeAndArchitectureStringHelperRundata.VehicleClassification),
+												typeof(IDeclarationInputDataProvider),
+												typeof(IDeclarationReport)
+											}
+										),
+									typeof(IInternalRunDataFactoryFactory)
+										.GetMethod(nameof(IInternalRunDataFactoryFactory
+											.CreateDeclarationCompletedBusRunDataFactory)//, 
+											//new []
+											//{
+											//	typeof(VehicleTypeAndArchitectureStringHelperRundata.VehicleClassification),
+											//	typeof(IDeclarationInputDataProvider),
+											//	typeof(IDeclarationReport)
+											//}
+											)
+								},
+								skipArguments = 1,
+								takeArguments = 1,
+							}
+						)).InSingletonScope();
 
 
 			#region Lorries
diff --git a/VectoCore/VectoCore/Ninject/VectoNinjectModule.cs b/VectoCore/VectoCore/Ninject/VectoNinjectModule.cs
index e22702945c..aa699476a0 100644
--- a/VectoCore/VectoCore/Ninject/VectoNinjectModule.cs
+++ b/VectoCore/VectoCore/Ninject/VectoNinjectModule.cs
@@ -29,6 +29,10 @@
 *   Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology
 */
 
+#if(MOCKUP)
+using System.IO;
+using System.Reflection;
+#endif
 using Ninject.Modules;
 using TUGraz.VectoCore.InputData.FileIO.XML;
 using TUGraz.VectoCore.InputData.Reader;
@@ -98,12 +102,6 @@ namespace TUGraz.VectoCore
 			var assembly = Assembly.LoadFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),"VectoMockup.dll"));
 			//var assembly = Assembly.LoadFile("VectoMockup.dll");
 			Kernel.Load(new Assembly[]{assembly});
-			
-
-
-
-
-
 #endif
 
 
diff --git a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/CustomerInformationFile_0_9/CIFNinjectModule.cs b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/CustomerInformationFile_0_9/CIFNinjectModule.cs
index 9391001d4f..16ba40067b 100644
--- a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/CustomerInformationFile_0_9/CIFNinjectModule.cs
+++ b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/CustomerInformationFile_0_9/CIFNinjectModule.cs
@@ -25,8 +25,17 @@ namespace TUGraz.VectoCore.OutputData.XML.DeclarationReports.CustomerInformation
 		public override void Load()
 		{
 			LoadModule<ContextPreservationModule>();
-			Bind<ICustomerInformationFileFactory>().ToFactory(() => new CombineArgumentsToNameInstanceProvider(MRFNinjectModule.VehicleTypeAndArchitectureStringHelper.CreateName, 6, 6, typeof(ICustomerInformationFileFactory).GetMethod(nameof(ICustomerInformationFileFactory
-					.GetCustomerReport)))).InSingletonScope();
+			Bind<ICustomerInformationFileFactory>().ToFactory(() => new CombineArgumentsToNameInstanceProvider(
+				new CombineArgumentsToNameInstanceProvider.MethodSettings()
+				{
+					combineToNameDelegate = VehicleTypeAndArchitectureStringHelper.CreateName,
+					skipArguments = 6,
+					takeArguments = 6,
+					methods = new[] {
+						typeof(ICustomerInformationFileFactory).GetMethod(
+							nameof(ICustomerInformationFileFactory.GetCustomerReport))
+					}
+				})).InSingletonScope();
 
 			#region Lorry CIF
 			Bind<IXMLCustomerReport>().To<ConventionalLorry_CIF>().Named(MRFNinjectModule.VehicleTypeAndArchitectureStringHelper.CreateName(MRFNinjectModule.VehicleTypeAndArchitectureStringHelper.ToParams(VehicleCategoryHelper.Lorry, VectoSimulationJobType.ConventionalVehicle,
diff --git a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/ManufacturerReport/ManufacturerReport_0_9/MRFNinjectModule.cs b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/ManufacturerReport/ManufacturerReport_0_9/MRFNinjectModule.cs
index 50bcc80485..c8823dee86 100644
--- a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/ManufacturerReport/ManufacturerReport_0_9/MRFNinjectModule.cs
+++ b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/ManufacturerReport/ManufacturerReport_0_9/MRFNinjectModule.cs
@@ -34,8 +34,17 @@ namespace TUGraz.VectoCore.OutputData.XML.DeclarationReports.ManufacturerReport.
 		public override void Load()
 		{
 			LoadModule<ContextPreservationModule>();
-			Bind<IManufacturerReportFactory>().ToFactory(() => new CombineArgumentsToNameInstanceProvider(VehicleTypeAndArchitectureStringHelper.CreateName, 
-				6, 6, typeof(IManufacturerReportFactory).GetMethod(nameof(IManufacturerReportFactory.GetManufacturerReport)))).InSingletonScope();
+			Bind<IManufacturerReportFactory>().ToFactory(() => new CombineArgumentsToNameInstanceProvider(
+				new CombineArgumentsToNameInstanceProvider.MethodSettings() {
+					combineToNameDelegate = VehicleTypeAndArchitectureStringHelper.CreateName,
+					skipArguments = 6,
+					takeArguments = 6,
+					methods = new[] {
+						typeof(IManufacturerReportFactory).GetMethod(
+							nameof(IManufacturerReportFactory.GetManufacturerReport))
+					}
+				})).InSingletonScope();
+
 			Bind<IXMLManufacturerReport>().To<ConventionalLorryManufacturerReport>()
 				.NamedLikeFactoryMethod((IManufacturerReportFactory f) => f.GetConventionalLorryManufacturerReport());
 
diff --git a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/VehicleInformationFile/VehicleInformationFile_0_1/VIFNinjectModule.cs b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/VehicleInformationFile/VehicleInformationFile_0_1/VIFNinjectModule.cs
index 86fd335d1a..ecaeea63e5 100644
--- a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/VehicleInformationFile/VehicleInformationFile_0_1/VIFNinjectModule.cs
+++ b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/VehicleInformationFile/VehicleInformationFile_0_1/VIFNinjectModule.cs
@@ -22,13 +22,31 @@ namespace TUGraz.VectoCore.OutputData.XML.DeclarationReports.VehicleInformationF
 		{
 			LoadModule<ContextPreservationModule>();
 
-			Bind<IVIFReportInterimFactory>().ToFactory(() => new CombineArgumentsToNameInstanceProvider(VehicleTypeAndArchitectureStringHelper.CreateName,
-				6, 6, 
-				typeof(IVIFReportInterimFactory).GetMethod(nameof(IVIFReportInterimFactory.GetInterimVIFReport)) )).InSingletonScope();
+			Bind<IVIFReportInterimFactory>().ToFactory(() => new CombineArgumentsToNameInstanceProvider(
+				new CombineArgumentsToNameInstanceProvider.MethodSettings()
+				{
+					combineToNameDelegate = VehicleTypeAndArchitectureStringHelper.CreateName,
+					skipArguments = 6,
+					takeArguments = 6,
+					methods = new[] {
+						typeof(IVIFReportInterimFactory).GetMethod(
+							nameof(IVIFReportInterimFactory.GetInterimVIFReport))
+					}
+				})).InSingletonScope();
+
+
+			Bind<IVIFReportFactory>().ToFactory(() => new CombineArgumentsToNameInstanceProvider(
+				new CombineArgumentsToNameInstanceProvider.MethodSettings()
+				{
+					combineToNameDelegate = VehicleTypeAndArchitectureStringHelper.CreateName,
+					skipArguments = 6,
+					takeArguments = 6,
+					methods = new[] {
+						typeof(IVIFReportFactory).GetMethod(
+							nameof(IVIFReportFactory.GetVIFReport))
+					}
+				})).InSingletonScope();
 
-			Bind<IVIFReportFactory>().ToFactory(() => new CombineArgumentsToNameInstanceProvider(VehicleTypeAndArchitectureStringHelper.CreateName,
-				6, 6, typeof(IVIFReportFactory).GetMethod(nameof(IVIFReportFactory.GetVIFReport))
-				)).InSingletonScope();
 			
 			
 			#region Primary Vehicle Information File Reports
diff --git a/VectoCore/VectoCore/Utils/Ninject/CombineArgumentsToNameInstanceProviders.cs b/VectoCore/VectoCore/Utils/Ninject/CombineArgumentsToNameInstanceProviders.cs
index 99621d5567..bd593b0387 100644
--- a/VectoCore/VectoCore/Utils/Ninject/CombineArgumentsToNameInstanceProviders.cs
+++ b/VectoCore/VectoCore/Utils/Ninject/CombineArgumentsToNameInstanceProviders.cs
@@ -12,33 +12,49 @@ using TUGraz.VectoCommon.Exceptions;
 
 namespace TUGraz.VectoCore.Utils.Ninject
 {
-    internal class CombineArgumentsToNameInstanceProvider : StandardInstanceProvider
+    public class CombineArgumentsToNameInstanceProvider : StandardInstanceProvider
 	{
+		public class MethodSettings
+		{
+			/// <summary>
+			/// This delegate is used to create a name out of the parameters
+			/// </summary>
+			public CombineToName combineToNameDelegate;
+			/// <summary>
+			/// Specifies the number of arguments that not passed to the constructor
+			/// </summary>
+			public int skipArguments;
+			/// <summary>
+			/// Specifies the number of arguments that are passed to the <see cref="combineToNameDelegate"/>
+			/// </summary>
+			public int takeArguments;
+			/// <summary>
+			/// Sets the methods for which these settings apply, leave empty for default settings
+			/// </summary>
+			public MethodInfo[] methods;
+		}
 
 		public delegate string CombineToName(params object[] arguments);
 
-		private CombineToName _combinationDelegate = null;
-		private readonly int _skipArgumentsNr;
-		private readonly int _numberOfArguments;
-
-		private HashSet<MethodInfo> _methodInfos = new HashSet<MethodInfo>();
+		private Dictionary<MethodInfo, MethodSettings> _methodSettings = new Dictionary<MethodInfo, MethodSettings>();
 		/// <summary>
 		/// Constructor for CombineArgumentsToNameInstanceProvider
 		/// </summary>
-		/// <param name="combinationDelegate">this delegate is to combine numberOfArguments arguments to a name</param>
-		/// <param name="numberOfArguments">the number of arguments that are used to create the name</param>
-		/// <param name="methods">the name is only resolved with the combinationDelegate if one of these methods was called, otherwise the standard instance provider is used</param>
-		/// <param name="skipArgumentsNr">defines the number of arguments that are skipped and not passed to the constructor</param>
-		public CombineArgumentsToNameInstanceProvider(CombineToName combinationDelegate, int numberOfArguments, int skipArgumentsNr, params MethodInfo[] methods)
+		
+		public CombineArgumentsToNameInstanceProvider(params MethodSettings[] settings)
 		{
-			_numberOfArguments = numberOfArguments;
-			_skipArgumentsNr = skipArgumentsNr;
-			_combinationDelegate = combinationDelegate;
+			if (settings != null && settings.Any(s => s.methods == null)) {
+				throw new ArgumentException($"At least one method has to be specified in the MethodSetting");
+			}
 
-			if (methods != null) {
-				foreach (var method in methods) {
-					_methodInfos.Add(method);
+
+			if (settings != null) {
+				foreach (var setting in settings) {
+					foreach (var method in setting.methods) {
+						_methodSettings.Add(method, setting);
+					}
 				}
+				
 			}
 		}
 
@@ -50,29 +66,31 @@ namespace TUGraz.VectoCore.Utils.Ninject
 			{
 				return base.GetInstance(instanceResolver, methodInfo, arguments);
 			}
-			catch (Exception e)
-			{
-				throw new VectoException("failed to create instance for '{1}' via '{0}' version '{2}'", e, methodInfo.Name, methodInfo.ReturnType.Name, arguments[0]);
+			catch (Exception e) {
+				var name = GetName(methodInfo, arguments);
+				throw new VectoException("failed to create instance for '{1}' via '{0}' version '{2}' name'{3}'", e, methodInfo.Name, methodInfo.ReturnType.Name, arguments[0], name);
+				
 				//throw e;
 			}
 		}
 
 		protected override string GetName(MethodInfo methodInfo, object[] arguments)
 		{
-			if (!_methodInfos.Contains(methodInfo)) {
+			if (!_methodSettings.TryGetValue(methodInfo, out var methodSettings)) {
 				return base.GetName(methodInfo, arguments);
 			}
 
-			return _combinationDelegate.Invoke(arguments.Take(_numberOfArguments).ToArray());
+			return methodSettings.combineToNameDelegate.Invoke(arguments.Take(methodSettings.takeArguments).ToArray());
 
 		}
 
 		protected override IConstructorArgument[] GetConstructorArguments(MethodInfo methodInfo, object[] arguments)
 		{
-			if (!_methodInfos.Contains(methodInfo)) {
+			if (!_methodSettings.TryGetValue(methodInfo, out var methodSettings)) {
 				return base.GetConstructorArguments(methodInfo, arguments);
 			}
-			return base.GetConstructorArguments(methodInfo, arguments).Skip(_skipArgumentsNr).ToArray();
+
+			return base.GetConstructorArguments(methodInfo, arguments).Skip(methodSettings.skipArguments).ToArray();
 		}
 
 		#endregion
diff --git a/VectoCore/VectoCore/Utils/Ninject/VehicleTypeAndArchitectureStringHelper.cs b/VectoCore/VectoCore/Utils/Ninject/VehicleTypeAndArchitectureStringHelper.cs
index f737f5c18d..1ffc336f72 100644
--- a/VectoCore/VectoCore/Utils/Ninject/VehicleTypeAndArchitectureStringHelper.cs
+++ b/VectoCore/VectoCore/Utils/Ninject/VehicleTypeAndArchitectureStringHelper.cs
@@ -1,5 +1,7 @@
 using System;
+using System.Linq;
 using System.Data.Common;
+using System.Diagnostics;
 using System.Threading;
 using TUGraz.VectoCommon.InputData;
 using TUGraz.VectoCommon.Models;
@@ -7,7 +9,7 @@ using TUGraz.VectoCore.OutputData.XML.DeclarationReports.CustomerInformationFile
 
 namespace TUGraz.VectoCore.Utils.Ninject
 {
-	internal interface IVehicleTypeAndArchitectureStringHelper
+	public interface IVehicleTypeAndArchitectureStringHelperReport
 	{
 		string GetName(string vehicleType, VectoSimulationJobType jobType, ArchitectureID archId = ArchitectureID.UNKNOWN,
 			bool exempted = false, bool iepc = false, bool ihpc = false);
@@ -18,33 +20,11 @@ namespace TUGraz.VectoCore.Utils.Ninject
 		CombineArgumentsToNameInstanceProvider.CombineToName CreateName { get; }
 	}
 
-	internal abstract class VehicleTypeAndArchitectureStringHelperReportBase : IVehicleTypeAndArchitectureStringHelper
-	{
-		public string GetName(string vehicleType, VectoSimulationJobType jobType, ArchitectureID archId = ArchitectureID.UNKNOWN,
-			bool exempted = false, bool iepc = false, bool ihpc = false)
-		{
-			
-			return CreateName(ToParams(vehicleType, jobType, archId, exempted, iepc, ihpc));
-		}
-
-		
-
-		public object[] ToParams(string vehicleType, VectoSimulationJobType jobType, ArchitectureID archId,
-			bool exempted, bool iepc, bool ihpc)
-		{
-			if (!VehicleCategoryHelper.SuperCategories.Contains(vehicleType)) {
-				throw new Exception(
-					$"String provided for {nameof(vehicleType)} must match the strings in {nameof(VehicleCategoryHelper.SuperCategories)}");
-			};
-			return new[] { (object)vehicleType, jobType, archId, exempted, iepc, ihpc};
-		}
-
-		public abstract CombineArgumentsToNameInstanceProvider.CombineToName CreateName { get; }
-	}
+	
 
-	internal class VehicleTypeAndArchitectureStringHelperReport : VehicleTypeAndArchitectureStringHelperReportBase
+	public class VehicleTypeAndArchitectureStringHelperReport : IVehicleTypeAndArchitectureStringHelperReport
 	{
-		public override CombineArgumentsToNameInstanceProvider.CombineToName CreateName { get; } = (arguments => {
+		public  CombineArgumentsToNameInstanceProvider.CombineToName CreateName { get; } = (arguments => {
 
 			//may be called with first argument of type string (when defining the bindings) or VehicleCategory when using the factory
 			string vehicleType = arguments[0] as string;
@@ -90,37 +70,82 @@ namespace TUGraz.VectoCore.Utils.Ninject
 
 			return result;
 		});
+		public virtual string GetName(string vehicleType, VectoSimulationJobType jobType, ArchitectureID archId = ArchitectureID.UNKNOWN,
+			bool exempted = false, bool iepc = false, bool ihpc = false)
+		{
+
+			return CreateName(ToParams(vehicleType, jobType, archId, exempted, iepc, ihpc));
+		}
+
+
+
+		public virtual object[] ToParams(string vehicleType, VectoSimulationJobType jobType, ArchitectureID archId,
+			bool exempted, bool iepc, bool ihpc)
+		{
+			if (!VehicleCategoryHelper.SuperCategories.Contains(vehicleType))
+			{
+				throw new Exception(
+					$"String provided for {nameof(vehicleType)} must match the strings in {nameof(VehicleCategoryHelper.SuperCategories)}");
+			};
+			return new[] { (object)vehicleType, jobType, archId, exempted, iepc, ihpc };
+		}
 	}
 
-	internal class VehicleTypeAndArchitectureStringHelperRundata : VehicleTypeAndArchitectureStringHelperReportBase
+	public class VehicleTypeAndArchitectureStringHelperRundata
 	{
-		public override CombineArgumentsToNameInstanceProvider.CombineToName CreateName { get; } = (arguments => {
-			string identifier = "";
-			//may be called with first argument of type string (when defining the bindings) or VehicleCategory when using the factory
-			string vehicleType = arguments[0] as string;
-			if (arguments[0] is VehicleCategory vehicleCategory)
-			{
-				vehicleType = vehicleCategory.GetVehicleType();
+		public CombineArgumentsToNameInstanceProvider.CombineToName CreateName { get; } = arguments => {
+			if (arguments[0] is VehicleClassification classification) {
+				return classification.GetHashCode().ToString();
+			} else {
+				throw new ArgumentException($"{nameof(arguments)}[0] must be of type {typeof(VehicleClassification)}");
 			}
+		};
 
+		#region Overrides of VehicleTypeAndArchitectureStringHelperReportBase
 
+		private string GetName(VehicleClassification classification)
+		{
+			return classification.GetHashCode().ToString();
+		}
 
-			VectoSimulationJobType jobType = (VectoSimulationJobType)arguments[1];
-			ArchitectureID archId = (ArchitectureID)arguments[2];
-			bool exempted = (bool)arguments[3];
-			bool iepc = (bool)arguments[4];
-			bool ihpc = (bool)arguments[5];
-			var vehicleClassification = new VehicleClassification(jobType, archId, vehicleType, exempted, iepc, ihpc);
+		public string GetName(string vehicleType, VectoSimulationJobType jobType, ArchitectureID archId = ArchitectureID.UNKNOWN,
+			bool exempted = false, bool iepc = false, bool ihpc = false)
+		{
+			return GetName(new VehicleClassification(jobType, archId, vehicleType, exempted, iepc, ihpc));
+		}
 
+		#endregion
 
+		public struct VehicleClassification
+		{
 
+			private VectoSimulationJobType JobType { get; }
+			private ArchitectureID ArchId { get; }
+			private string VehicleType { get; }
+			private bool Exempted { get; }
+			private bool Iepc { get; }
+			private bool Ihpc { get; }
 
-			return vehicleClassification.GetHashCode().ToString();
-		});
+			public VehicleClassification(VectoSimulationJobType jobType, ArchitectureID archId, string vehicleType, bool exempted, bool iepc, bool ihpc)
+			{
+				Iepc = iepc;
+				Ihpc = ihpc;
+				Exempted = exempted;
+				VehicleType = vehicleType;
+				ArchId = archId;
+				JobType = jobType;
+			}
 
-		private struct VehicleClassification
-		{
-			#region Equality members
+			public VehicleClassification(IVehicleDeclarationInputData inputData)
+			{
+				Iepc = (inputData.Components?.ElectricMachines?.Entries)?.Count(electric => electric.ElectricMachine.IHPCType != "None") > 0;
+				Ihpc = (inputData.Components?.IEPC != null);
+				Exempted = inputData.ExemptedVehicle;
+				VehicleType = inputData.VehicleCategory.GetVehicleType();
+				ArchId = inputData.ArchitectureID;
+				JobType = inputData.VehicleType;
+				
+			}
 
 			public bool Equals(VehicleClassification other)
 			{
@@ -134,7 +159,8 @@ namespace TUGraz.VectoCore.Utils.Ninject
 
 			public override int GetHashCode()
 			{
-				unchecked {
+				unchecked
+				{
 					var hashCode = (int)JobType;
 					hashCode = (hashCode * 397) ^ (int)ArchId;
 					hashCode = (hashCode * 397) ^ (VehicleType != null ? VehicleType.GetHashCode() : 0);
@@ -144,27 +170,6 @@ namespace TUGraz.VectoCore.Utils.Ninject
 					return hashCode;
 				}
 			}
-
-			#endregion
-
-			private VectoSimulationJobType JobType { get; }
-			private ArchitectureID ArchId { get; }
-			private string VehicleType { get; }
-			private bool Exempted { get; }
-			private bool Iepc { get; }
-			private bool Ihpc { get; }
-
-			public VehicleClassification(VectoSimulationJobType jobType, ArchitectureID archId, string vehicleType, bool exempted, bool iepc, bool ihpc)
-			{
-				ArchId = archId;
-				JobType = jobType;
-				ArchId = archId;
-				VehicleType = vehicleType;
-				Exempted = exempted;
-				Iepc = iepc;
-				Ihpc = ihpc;
-			}
-
 		}
 	}
 }
\ No newline at end of file
-- 
GitLab