diff --git a/HashingCmd/Program.cs b/HashingCmd/Program.cs index 4312d075b94040dbf2f8fe7e328169e618ee263c..e88664d9d276b938cf40d9fbf3200522709679b3 100644 --- a/HashingCmd/Program.cs +++ b/HashingCmd/Program.cs @@ -258,7 +258,7 @@ hashingcmd.exe { var hashingLib = Assembly.LoadFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "VectoHashing.dll")) .GetName(); - WriteLine(string.Format(@"HashingLibrary: {0}", hashingLib.Version)); + WriteLine($@"HashingLibrary: {hashingLib.Version}"); } } } \ No newline at end of file diff --git a/HashingTool/MainWindow.xaml.cs b/HashingTool/MainWindow.xaml.cs index 228940f9436e7b52cacbf781a2422b34e7dbb0a6..34680d35ec702702471214ab103d460410f044f0 100644 --- a/HashingTool/MainWindow.xaml.cs +++ b/HashingTool/MainWindow.xaml.cs @@ -65,7 +65,7 @@ namespace HashingTool var myAppPath = AppDomain.CurrentDomain.BaseDirectory; if (File.Exists(myAppPath + @"User Manual\HashingToolHelp.html")) { var defaultBrowserPath = BrowserHelper.GetDefaultBrowserPath(); - Process.Start(defaultBrowserPath, string.Format("\"file://{0}{1}\"", myAppPath, @"User Manual\HashingToolHelp.html")); + Process.Start(defaultBrowserPath, $"\"file://{myAppPath}{@"User Manual\HashingToolHelp.html"}\""); } else { MessageBox.Show("User Manual not found!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } diff --git a/HashingTool/ViewModel/ApplicationViewModel.cs b/HashingTool/ViewModel/ApplicationViewModel.cs index 500016b934d43ee023306f5fb01436db4ca23c80..1b5696ac3592a61f74cef97ca854067d4266ff97 100644 --- a/HashingTool/ViewModel/ApplicationViewModel.cs +++ b/HashingTool/ViewModel/ApplicationViewModel.cs @@ -103,6 +103,6 @@ namespace HashingTool.ViewModel CurrentViewModel = MainViewModels.FirstOrDefault(mv => mv == mainView); } - public string VersionInformation => string.Format("Vecto Hashing Tool {0} / Hashing Library {1}", _myVersion, _hashingLib); + public string VersionInformation => $"Vecto Hashing Tool {_myVersion} / Hashing Library {_hashingLib}"; } } diff --git a/HashingTool/ViewModel/UserControl/ManufacturerReportXMLFile.cs b/HashingTool/ViewModel/UserControl/ManufacturerReportXMLFile.cs index 6661fe0a93bc42ee7533000e0fef6d0c01473bdb..f0ac778e9b7fc85703e8352988e2b0bac5d0868a 100644 --- a/HashingTool/ViewModel/UserControl/ManufacturerReportXMLFile.cs +++ b/HashingTool/ViewModel/UserControl/ManufacturerReportXMLFile.cs @@ -100,7 +100,7 @@ namespace HashingTool.ViewModel.UserControl var entry = new ComponentEntry { Component = component.Count == 1 ? component.Entry.XMLElementName() - : string.Format("{0} ({1})", component.Entry.XMLElementName(), i + 1), + : $"{component.Entry.XMLElementName()} ({i + 1})", DigestValue = ReadElementValue(node, XMLNames.DI_Signature_Reference_DigestValue), CertificationMethod = ReadElementValue(node, XMLNames.Report_Component_CertificationMethod), }; @@ -167,7 +167,7 @@ namespace HashingTool.ViewModel.UserControl private string ReadElementValue(XmlNode xmlNode, string elementName) { - var node = xmlNode.SelectSingleNode(string.Format("./*[local-name()='{0}']", elementName)); + var node = xmlNode.SelectSingleNode($"./*[local-name()='{elementName}']"); if (node == null) { return null; } diff --git a/HashingTool/ViewModel/UserControl/VectoJobFile.cs b/HashingTool/ViewModel/UserControl/VectoJobFile.cs index 4dd5eb4b9d0f6d804b6ae492964653ca8300210b..9b477916dd57fbffa647b86583624d6af303a45f 100644 --- a/HashingTool/ViewModel/UserControl/VectoJobFile.cs +++ b/HashingTool/ViewModel/UserControl/VectoJobFile.cs @@ -129,7 +129,7 @@ namespace HashingTool.ViewModel.UserControl !_xmlFile.ContentValid.Value) { return null; } - var nodes = _xmlFile.Document.SelectNodes(string.Format("//*[local-name()='{0}']", XMLNames.Component_Date)); + var nodes = _xmlFile.Document.SelectNodes($"//*[local-name()='{XMLNames.Component_Date}']"); if (nodes == null || nodes.Count == 0) { return null; } @@ -142,7 +142,7 @@ namespace HashingTool.ViewModel.UserControl !_xmlFile.ContentValid.Value) { return ""; } - var node = _xmlFile.Document.SelectSingleNode(string.Format("//*[local-name()='{0}']", XMLNames.Vehicle_VIN)); + var node = _xmlFile.Document.SelectSingleNode($"//*[local-name()='{XMLNames.Vehicle_VIN}']"); if (node == null) { return ""; } @@ -175,7 +175,7 @@ namespace HashingTool.ViewModel.UserControl var entry = new ComponentEntry(); entry.Component = component.Count == 1 ? component.Entry.XMLElementName() - : string.Format("{0} ({1})", component.Entry.XMLElementName(), i + 1); + : $"{component.Entry.XMLElementName()} ({i + 1})"; entry.Valid = h.ValidateHash(component.Entry, i); entry.CanonicalizationMethod = h.GetCanonicalizationMethods(component.Entry, i).ToArray(); entry.DigestMethod = h.GetDigestMethod(component.Entry, i); diff --git a/HashingTool/ViewModel/UserControl/XMLFileSelector.cs b/HashingTool/ViewModel/UserControl/XMLFileSelector.cs index 17cadc6c8c7b531b100b63dd4d889e6fad8327fb..bfcf55f7a8d1c393938461ade154afa28ebf0538 100644 --- a/HashingTool/ViewModel/UserControl/XMLFileSelector.cs +++ b/HashingTool/ViewModel/UserControl/XMLFileSelector.cs @@ -251,7 +251,7 @@ namespace HashingTool.ViewModel.UserControl public void LogError(string message) { - XMLValidationErrors.Add(String.Format("{0}: {1}", _prefix, message)); + XMLValidationErrors.Add($"{_prefix}: {message}"); } public bool HasContentValidation { get; private set; } @@ -278,9 +278,7 @@ namespace HashingTool.ViewModel.UserControl () => { if (e.ValidationEventArgs == null) { LogError( - string.Format( - "XML file does not validate against a supported version of {0}", - _expectedDocumentType.ToString())); + $"XML file does not validate against a supported version of {_expectedDocumentType.ToString()}"); } else { LogError( string.Format( diff --git a/VectoCommon/VectoCommon/Models/IResponse.cs b/VectoCommon/VectoCommon/Models/IResponse.cs index 58f31382fea8bed036428516c871c276a83ed73e..15984e37ff64f469a95d3031c59a3b431becf25d 100644 --- a/VectoCommon/VectoCommon/Models/IResponse.cs +++ b/VectoCommon/VectoCommon/Models/IResponse.cs @@ -44,8 +44,7 @@ namespace TUGraz.VectoCommon.Models public override string ToString() { var t = GetType(); - return string.Format("{0}{{{1}}}", t.Name, - string.Join(", ", t.GetProperties().Select(p => string.Format("{0}: {1}", p.Name, p.GetValue(this))))); + return $"{t.Name}{{{string.Join(", ", t.GetProperties().Select(p => $"{p.Name}: {p.GetValue(this)}"))}}}"; } } diff --git a/VectoCommon/VectoCommon/Models/OperatingPoint.cs b/VectoCommon/VectoCommon/Models/OperatingPoint.cs index 97b7858fb60f3e5d4224471ef98fa0e90e9205c0..ec6565b5c814fa13d4711c4f4ff1148e89c0f8c5 100644 --- a/VectoCommon/VectoCommon/Models/OperatingPoint.cs +++ b/VectoCommon/VectoCommon/Models/OperatingPoint.cs @@ -55,7 +55,7 @@ namespace TUGraz.VectoCommon.Models public override string ToString() { - return string.Format("a: {0}, dt: {1}, ds: {2}", Acceleration, SimulationInterval, SimulationDistance); + return $"a: {Acceleration}, dt: {SimulationInterval}, ds: {SimulationDistance}"; } } diff --git a/VectoCommon/VectoCommon/Models/TorqueConverterOperatingPoint.cs b/VectoCommon/VectoCommon/Models/TorqueConverterOperatingPoint.cs index fa5f6a62c8477d34bbd4f9ec80b3a4607de4ae75..f728d8ed7886209d96d6e5220a1dd46571b4d273 100644 --- a/VectoCommon/VectoCommon/Models/TorqueConverterOperatingPoint.cs +++ b/VectoCommon/VectoCommon/Models/TorqueConverterOperatingPoint.cs @@ -15,8 +15,7 @@ namespace TUGraz.VectoCommon.Models { public override string ToString() { - return string.Format("n_out: {0}, n_in: {1}, tq_out: {2}, tq_in {3}, nu: {4}, my: {5}", OutAngularVelocity, - InAngularVelocity, OutTorque, InTorque, SpeedRatio, TorqueRatio); + return $"n_out: {OutAngularVelocity}, n_in: {InAngularVelocity}, tq_out: {OutTorque}, tq_in {InTorque}, nu: {SpeedRatio}, my: {TorqueRatio}"; } } } \ No newline at end of file diff --git a/VectoCommon/VectoCommon/Utils/SI.cs b/VectoCommon/VectoCommon/Utils/SI.cs index 915ddab15ce98f6ca9c8a0e9375ee90604431b33..8a17596554c75fb33b6a808f768e664d7eff6000 100644 --- a/VectoCommon/VectoCommon/Utils/SI.cs +++ b/VectoCommon/VectoCommon/Utils/SI.cs @@ -1596,7 +1596,7 @@ namespace TUGraz.VectoCommon.Utils } } catch (DivideByZeroException ex) { throw new VectoException( - string.Format("Can not compute division by zero ([{0}] / 0[{1}])", si1.UnitString, si2.UnitString), ex); + $"Can not compute division by zero ([{si1.UnitString}] / 0[{si2.UnitString}])", ex); } var unitArray = SIUtils.CombineUnits(si1._units, SIUtils.MultiplyUnits(si2._units, -1)); @@ -1608,7 +1608,7 @@ namespace TUGraz.VectoCommon.Utils public static SI operator /(SI si1, double d) { if (d.IsEqual(0)) { - throw new VectoException(string.Format("Can not compute division by zero ([{0}] / 0)", si1.UnitString), new DivideByZeroException()); + throw new VectoException($"Can not compute division by zero ([{si1.UnitString}] / 0)", new DivideByZeroException()); } return new SI(si1.Val / d, si1); @@ -1618,7 +1618,7 @@ namespace TUGraz.VectoCommon.Utils public static SI operator /(double d, SI si1) { if (si1.IsEqual(0)) { - throw new VectoException(string.Format("Can not compute division by zero (x / 0[{0}])", si1.UnitString), + throw new VectoException($"Can not compute division by zero (x / 0[{si1.UnitString}])", new DivideByZeroException()); } diff --git a/VectoCommon/VectoCommon/Utils/Validation.cs b/VectoCommon/VectoCommon/Utils/Validation.cs index 63765792b2942057cfbfd4bba725766cce6b710f..7eed7002cd068f04442989191880ec289861040f 100644 --- a/VectoCommon/VectoCommon/Utils/Validation.cs +++ b/VectoCommon/VectoCommon/Utils/Validation.cs @@ -62,7 +62,7 @@ namespace TUGraz.VectoCommon.Utils bool emsCycle) { if (entity == null) { - return new[] { new ValidationResult(string.Format("null value given for {0}", typeof(T))) }; + return new[] { new ValidationResult($"null value given for {typeof(T)}") }; } var context = new ValidationContext(entity); context.ServiceContainer.AddService(typeof(VectoValidationModeServiceContainer), @@ -231,7 +231,7 @@ namespace TUGraz.VectoCommon.Utils return new ValidationResult(string.Join("\n", results), messages); } return new ValidationResult( - string.Format("{{{0}}} invalid: {1}", validationContext.DisplayName, string.Join("\n", results)), messages); + $"{{{validationContext.DisplayName}}} invalid: {string.Join("\n", results)}", messages); } return ValidationResult.Success; diff --git a/VectoCommon/VectoHashing/Impl/XmlHashProvider.cs b/VectoCommon/VectoHashing/Impl/XmlHashProvider.cs index 6a7c781da008b5c301123a692d944000b408190e..b8dac3e01db12e69c07f1fc649478763a705148b 100644 --- a/VectoCommon/VectoHashing/Impl/XmlHashProvider.cs +++ b/VectoCommon/VectoHashing/Impl/XmlHashProvider.cs @@ -86,11 +86,11 @@ namespace TUGraz.VectoHashing.Impl var c14N = (canonicalization ?? DefaultCanonicalizationMethod).ToArray(); digestMethod = digestMethod ?? DefaultDigestMethod; if (!SupportedDigestMethods.Contains(digestMethod)) { - throw new Exception(string.Format("DigestMethod '{0}' not supported.", digestMethod)); + throw new Exception($"DigestMethod '{digestMethod}' not supported."); } var unsupported = c14N.Where(c => !SupportedCanonicalizationMethods.Contains(c)).ToArray(); if (unsupported.Any()) { - throw new Exception(string.Format("CanonicalizationMethod(s) {0} not supported!", string.Join(", ", unsupported))); + throw new Exception($"CanonicalizationMethod(s) {string.Join(", ", unsupported)} not supported!"); } var signedXml = new SignedXml(doc); @@ -120,7 +120,7 @@ namespace TUGraz.VectoHashing.Impl case DsigExcC14NTransform: return new XmlDsigExcC14NTransform(); } - throw new Exception(string.Format("Unsupported CanonicalizationMethod {0}", transformUrn)); + throw new Exception($"Unsupported CanonicalizationMethod {transformUrn}"); } } } diff --git a/VectoCommon/VectoHashing/VectoHash.cs b/VectoCommon/VectoHashing/VectoHash.cs index 3f8927af6a34ff87a2164a8fd0697d08746ea24f..be5bb557ff3b0980b2539f2dfea3007df251c437 100644 --- a/VectoCommon/VectoHashing/VectoHash.cs +++ b/VectoCommon/VectoHashing/VectoHash.cs @@ -149,11 +149,10 @@ namespace TUGraz.VectoHashing var nodes = Document.SelectNodes(GetComponentQueryString(component)); if (nodes == null || nodes.Count == 0) { - throw new Exception(string.Format("Component {0} not found", component.XMLElementName())); + throw new Exception($"Component {component.XMLElementName()} not found"); } if (index >= nodes.Count) { - throw new Exception(string.Format("index exceeds number of components found! index: {0}, #components: {1}", index, - nodes.Count)); + throw new Exception($"index exceeds number of components found! index: {index}, #components: {nodes.Count}"); } var componentId = nodes[index].Attributes[XMLNames.Component_ID_Attr].Value; return GetHashValueFromSig(DoComputeHash(nodes[index], canonicalization, digestMethod), componentId); @@ -213,12 +212,12 @@ namespace TUGraz.VectoHashing public XDocument AddHash() { var component = GetComponentToHash(); - var query = string.Format("//*[local-name()='{0}']/*[local-name()='Data']", component.XMLElementName()); + var query = $"//*[local-name()='{component.XMLElementName()}']/*[local-name()='Data']"; var node = Document.SelectSingleNode(query); if (node == null) { - throw new Exception(string.Format("'Data' element for component '{0}' not found!", component.XMLElementName())); + throw new Exception($"'Data' element for component '{component.XMLElementName()}' not found!"); } - query = string.Format("//*[local-name()='{0}']/*[local-name()='Signature']", component.XMLElementName()); + query = $"//*[local-name()='{component.XMLElementName()}']/*[local-name()='Signature']"; var sigNodes = Document.SelectNodes(query); if (sigNodes != null && sigNodes.Count > 0) { throw new Exception("input data already contains a signature element"); @@ -246,7 +245,7 @@ namespace TUGraz.VectoHashing query = component.IsReport() ? "*/*[local-name()='Data']/*[local-name()='ApplicationInformation']/*[local-name()='Date']" - : string.Format("*/*[local-name()='{0}']/*/*[local-name()='Date']", component.XMLElementName()); + : $"*/*[local-name()='{component.XMLElementName()}']/*/*[local-name()='Date']"; var dateNode = Document.SelectSingleNode(query); if (dateNode == null) { throw new Exception("Date-Element not found in input!"); @@ -361,9 +360,9 @@ namespace TUGraz.VectoHashing private string ReadElementValue(XmlNode xmlNode, string elementName) { - var node = xmlNode.SelectSingleNode(string.Format("./*[local-name()='{0}']", elementName)); + var node = xmlNode.SelectSingleNode($"./*[local-name()='{elementName}']"); if (node == null) { - throw new Exception(string.Format("Node '{0}' not found!", elementName)); + throw new Exception($"Node '{elementName}' not found!"); } return node.InnerText; } @@ -380,11 +379,10 @@ namespace TUGraz.VectoHashing if (nodes == null || nodes.Count == 0) { throw new Exception(component == null ? "No component found" - : string.Format("Component {0} not found", component.Value.XMLElementName())); + : $"Component {component.Value.XMLElementName()} not found"); } if (index >= nodes.Count) { - throw new Exception(string.Format("index exceeds number of components found! index: {0}, #components: {1}", index, - nodes.Count)); + throw new Exception($"index exceeds number of components found! index: {index}, #components: {nodes.Count}"); } return nodes; } @@ -408,8 +406,8 @@ namespace TUGraz.VectoHashing return "(//*[@id])[1]"; } return component == VectoComponents.Vehicle - ? string.Format("//*[local-name()='{0}']", component.Value.XMLElementName()) - : string.Format("//*[local-name()='{0}']/*[local-name()='Data']", component.Value.XMLElementName()); + ? $"//*[local-name()='{component.Value.XMLElementName()}']" + : $"//*[local-name()='{component.Value.XMLElementName()}']/*[local-name()='Data']"; } private static string GetHashValueFromSig(XmlDocument hashed, string elementId) diff --git a/VectoConsole/Program.cs b/VectoConsole/Program.cs index d25b95d95e28f93c9a8719ce3f0c3e1d4e3a748f..8c1f723ef05f4d9bb13c7b8be5bf8b8209577aca 100644 --- a/VectoConsole/Program.cs +++ b/VectoConsole/Program.cs @@ -222,7 +222,7 @@ Examples: } if (dataProvider == null) { - WriteLine(string.Format(@"failed to read job: '{0}'", file)); + WriteLine($@"failed to read job: '{file}'"); continue; } @@ -241,7 +241,7 @@ Examples: WriteLine(@"Detected cycles:", ConsoleColor.White); foreach (var cycle in _jobContainer.GetCycleTypes()) { - WriteLineStdOut(string.Format(@" {0}: {1}", cycle.Name, cycle.CycleType)); + WriteLineStdOut($@" {cycle.Name}: {cycle.CycleType}"); } WriteLine(); @@ -355,8 +355,8 @@ Examples: private static void ShowVersionInformation() { - WriteLine(string.Format(@"VectoConsole: {0}", Assembly.GetExecutingAssembly().GetName().Version)); - WriteLine(string.Format(@"VectoCore: {0}", VectoSimulationCore.VersionNumber)); + WriteLine($@"VectoConsole: {Assembly.GetExecutingAssembly().GetName().Version}"); + WriteLine($@"VectoCore: {VectoSimulationCore.VersionNumber}"); } private static void PrintProgress(Dictionary<int, JobContainer.ProgressEntry> progessData, @@ -381,10 +381,9 @@ Examples: } var timingString = ""; if (showTiming && progressEntry.Value.ExecTime > 0) { - timingString = string.Format("{0,9:F2}s", progressEntry.Value.ExecTime / 1000.0); + timingString = $"{progressEntry.Value.ExecTime / 1000.0,9:F2}s"; } - var runName = string.Format("{0} {1} {2}", progressEntry.Value.RunName, progressEntry.Value.CycleName, - progressEntry.Value.RunSuffix); + var runName = $"{progressEntry.Value.RunName} {progressEntry.Value.CycleName} {progressEntry.Value.RunSuffix}"; Console.WriteLine(@"{0,-60} {1,8:P}{2}", runName, progressEntry.Value.Progress, timingString); Console.ResetColor(); sumProgress += progressEntry.Value.Progress; diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONGearboxData.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONGearboxData.cs index aa76ff09b5d034ca644a8061916ac3a752d82d0b..9d8d2be4c97c98590644e5b857ec00e084abc2b2 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONGearboxData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONGearboxData.cs @@ -262,12 +262,12 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON Ratio = nextRatio, LossMap = nextGear[JsonKeys.Gearbox_Gear_LossMapFile] != null ? ReadTableData(nextGear.GetEx<string>(JsonKeys.Gearbox_Gear_LossMapFile), - string.Format("Gear {0} LossMap", gearNr)) + $"Gear {gearNr} LossMap") : null, Efficiency = nextEfficiency, MaxTorque = gear["MaxTorque"] != null ? gear["MaxTorque"].Value<double>().SI<NewtonMeter>() : null, ShiftPolygon = ReadTableData(gear.GetEx<string>(JsonKeys.Gearbox_Gear_ShiftPolygonFile), - string.Format("Gear {0} shiftPolygon", gearNr), false), + $"Gear {gearNr} shiftPolygon", false), }; } @@ -288,7 +288,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON if (lossMap != null) { try { retVal.LossMap = ReadTableData(gear.GetEx<string>(JsonKeys.Gearbox_Gear_LossMapFile), - string.Format("Gear {0} LossMap", gearNumber)); + $"Gear {gearNumber} LossMap"); } catch (Exception) { if (!TolerateMissing) { throw; @@ -305,7 +305,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON if (shiftPolygonFile != null && !string.IsNullOrWhiteSpace(shiftPolygonFile.Value<string>())) { try { retVal.ShiftPolygon = ReadTableData(gear.GetEx<string>(JsonKeys.Gearbox_Gear_ShiftPolygonFile), - string.Format("Gear {0} shiftPolygon", gearNumber)); + $"Gear {gearNumber} shiftPolygon"); } catch (Exception) { retVal.ShiftPolygon = new TableData(Path.Combine(BasePath, shiftPolygonFile.Value<string>()) + MissingFileSuffix, DataSourceType.Missing); diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs index 94467ad7bd9f8f5f05759f62cee7680926244a30..07b7db4ab710862123b087c404253d0929d8a5cd 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs @@ -835,7 +835,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON x => new KeyValuePair<FuelType, JoulePerMeter>( x.Attributes.GetNamedItem(XMLNames.Report_Results_Fuel_Type_Attr).InnerText.ParseEnum<FuelType>(), x.SelectSingleNode( - string.Format("./*[local-name()='{0}' and @unit='MJ/km']", XMLNames.Report_Result_EnergyConsumption)) + $"./*[local-name()='{XMLNames.Report_Result_EnergyConsumption}' and @unit='MJ/km']") ?.InnerText .ToDouble().SI(Unit.SI.Mega.Joule.Per.Kilo.Meter).Cast<JoulePerMeter>())) .ToDictionary(x => x.Key, x => x.Value), diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationPTODataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationPTODataProvider.cs index a145ecb7c1c055fe2ab66c323c4768272da9fb39..4d6bb336ca74b8905224e32044647b0fc5634ffa 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationPTODataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationPTODataProvider.cs @@ -70,7 +70,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider } var otherElements = GetString(XMLNames.Vehicle_PTO_OtherElements); - var ptoTech = string.Format("{0} - {1}", shaftGearWheels, otherElements); + var ptoTech = $"{shaftGearWheels} - {otherElements}"; if (DeclarationData.PTOTransmission.GetTechnologies().Contains(ptoTech)) { return ptoTech; } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationPrimaryVehicleBusResultsInputDataProviderV01.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationPrimaryVehicleBusResultsInputDataProviderV01.cs index caf7fc362daa27d37f56b020f2f365781e831f23..21ae0bdaed5b9af7f160bd03ddaa1ff917a57e64 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationPrimaryVehicleBusResultsInputDataProviderV01.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationPrimaryVehicleBusResultsInputDataProviderV01.cs @@ -61,7 +61,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider .Cast<XmlNode>().Select(x => new KeyValuePair<FuelType, JoulePerMeter>( GetAttribute(x, XMLNames.Report_Results_Fuel_Type_Attr).ParseEnum<FuelType>(), x.SelectSingleNode( - string.Format(".//*[local-name()='{0}' and @unit='MJ/km']", XMLNames.Report_Result_EnergyConsumption))?.InnerText + $".//*[local-name()='{XMLNames.Report_Result_EnergyConsumption}' and @unit='MJ/km']")?.InnerText .ToDouble().SI(Unit.SI.Mega.Joule.Per.Kilo.Meter).Cast<JoulePerMeter>())).ToDictionary(x => x.Key, x => x.Value); diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/AbstractComponentReader.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/AbstractComponentReader.cs index e7e044d77d1ba68ac76e3c04339edd1f924ae77d..16c5fdc36b9dc5ca1e97b79cbbc6549ada8cf8a9 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/AbstractComponentReader.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/AbstractComponentReader.cs @@ -57,7 +57,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl ? BaseNode : BaseNode.SelectSingleNode(XMLHelper.QueryLocalName(component)); var dataNode = - componentNode?.SelectSingleNode(string.Format("./*[local-name()='{0}']", XMLNames.ComponentDataWrapper)); + componentNode?.SelectSingleNode($"./*[local-name()='{XMLNames.ComponentDataWrapper}']"); if (componentNode != null) { var type = (dataNode ?? componentNode).SchemaInfo.SchemaType; var version = XMLHelper.GetXsdType(type); diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/Reader/Impl/AbstractExternalResourceReader.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/Reader/Impl/AbstractExternalResourceReader.cs index 825bde69ac34d7c62058911123ccec2d27d1ef8e..4a894282a00066aab4d9ac594b8c5fc8e0def0aa 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/Reader/Impl/AbstractExternalResourceReader.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/Reader/Impl/AbstractExternalResourceReader.cs @@ -61,7 +61,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.Reader ? BaseNode : BaseNode.SelectSingleNode(XMLHelper.QueryLocalName(component)); var dataNode = requireDataNode - ? componentNode?.SelectSingleNode(string.Format("./*[local-name()='{0}']", XMLNames.ComponentDataWrapper)) + ? componentNode?.SelectSingleNode($"./*[local-name()='{XMLNames.ComponentDataWrapper}']") : componentNode; var componentResourceNode = componentNode?.SelectSingleNode( string.Format( @@ -113,7 +113,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.Reader ? componentDocument.DocumentElement : componentDocument.DocumentElement.SelectSingleNode(XMLHelper.QueryLocalName(component)); var docDataNode = - docComponentNode?.SelectSingleNode(string.Format("./*[local-name()='{0}']", XMLNames.ComponentDataWrapper)) ?? + docComponentNode?.SelectSingleNode($"./*[local-name()='{XMLNames.ComponentDataWrapper}']") ?? docComponentNode; var type = (docDataNode)?.SchemaInfo.SchemaType; diff --git a/VectoCore/VectoCore/InputData/FileIO/XMLReports/XMLManufacturerReportReader.cs b/VectoCore/VectoCore/InputData/FileIO/XMLReports/XMLManufacturerReportReader.cs index b72c19dd30d27e7fc9b1bb39979317578e6d7e26..751cc5faaed4dbf7a8842b465b5ce9420919554f 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XMLReports/XMLManufacturerReportReader.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XMLReports/XMLManufacturerReportReader.cs @@ -73,11 +73,10 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration { var nodes = xmlDocument.SelectNodes(GetComponentQueryString(component == VectoComponents.Tyre ? "Axle" : component.XMLElementName())); if (nodes == null || nodes.Count == 0) { - throw new Exception(string.Format("Component {0} not found", component)); + throw new Exception($"Component {component} not found"); } if (index >= nodes.Count) { - throw new Exception(string.Format("index exceeds number of components found! index: {0}, #components: {1}", index, - nodes.Count)); + throw new Exception($"index exceeds number of components found! index: {index}, #components: {nodes.Count}"); } return nodes[index]; } @@ -87,12 +86,12 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration if (component == null) { return "(//*[@id])[1]"; } - return string.Format("//*[local-name()='{0}']", component); + return $"//*[local-name()='{component}']"; } static string ReadElementValue(XmlNode xmlNode, string elementName) { - var node = xmlNode.SelectSingleNode(string.Format("./*[local-name()='{0}']", elementName)); + var node = xmlNode.SelectSingleNode($"./*[local-name()='{elementName}']"); if (node == null) { return null; } diff --git a/VectoCore/VectoCore/InputData/Reader/ComponentData/ElectricMotorMapReader.cs b/VectoCore/VectoCore/InputData/Reader/ComponentData/ElectricMotorMapReader.cs index 25ff21d243e816aa4ea17d93180e7b795e5e6ac3..72a14c618ceb8002b6feb9b33e3884e46cdc61a6 100644 --- a/VectoCore/VectoCore/InputData/Reader/ComponentData/ElectricMotorMapReader.cs +++ b/VectoCore/VectoCore/InputData/Reader/ComponentData/ElectricMotorMapReader.cs @@ -49,7 +49,7 @@ namespace TUGraz.VectoCore.InputData.Reader.ComponentData { } catch (Exception e) { - throw new VectoException(string.Format("EfficiencyMap - Line {0}: {1}", data.Rows.IndexOf(row), e.Message), e); + throw new VectoException($"EfficiencyMap - Line {data.Rows.IndexOf(row)}: {e.Message}", e); } } diff --git a/VectoCore/VectoCore/InputData/Reader/ComponentData/FuelConsumptionMapReader.cs b/VectoCore/VectoCore/InputData/Reader/ComponentData/FuelConsumptionMapReader.cs index 89b1f2847dc252e0fd8a6acf5a5670a8a701f423..448157e3b1054f9d65f33f9d90865283f3958c5a 100644 --- a/VectoCore/VectoCore/InputData/Reader/ComponentData/FuelConsumptionMapReader.cs +++ b/VectoCore/VectoCore/InputData/Reader/ComponentData/FuelConsumptionMapReader.cs @@ -49,7 +49,7 @@ namespace TUGraz.VectoCore.InputData.Reader.ComponentData var data = VectoCSVFile.Read(fileName); return Create(data); } catch (Exception e) { - throw new VectoException(string.Format("File {0}: {1}", fileName, e.Message), e); + throw new VectoException($"File {fileName}: {e.Message}", e); } } @@ -71,7 +71,7 @@ namespace TUGraz.VectoCore.InputData.Reader.ComponentData (headerValid ? row.ParseDouble(Fields.EngineSpeed) : row.ParseDouble(0)).RPMtoRad().Value(), entry.FuelConsumption.Value()); } catch (Exception e) { - throw new VectoException(string.Format("FuelConsumptionMap - Line {0}: {1}", data.Rows.IndexOf(row), e.Message), e); + throw new VectoException($"FuelConsumptionMap - Line {data.Rows.IndexOf(row)}: {e.Message}", e); } } diff --git a/VectoCore/VectoCore/InputData/Reader/ComponentData/WHRPowerReader.cs b/VectoCore/VectoCore/InputData/Reader/ComponentData/WHRPowerReader.cs index 4a4b209df19b1bcc8c249611aaddd91671f1c4ea..2a2cd8902c830293e179c754977a44d995941b33 100644 --- a/VectoCore/VectoCore/InputData/Reader/ComponentData/WHRPowerReader.cs +++ b/VectoCore/VectoCore/InputData/Reader/ComponentData/WHRPowerReader.cs @@ -19,7 +19,7 @@ namespace TUGraz.VectoCore.InputData.Reader.ComponentData var data = VectoCSVFile.Read(fileName); return Create(data, type); } catch (Exception e) { - throw new VectoException(string.Format("File {0}: {1}", fileName, e.Message), e); + throw new VectoException($"File {fileName}: {e.Message}", e); } } @@ -65,7 +65,7 @@ namespace TUGraz.VectoCore.InputData.Reader.ComponentData delaunayMap?.AddPoint(torque.Value(),engineSpeed.Value(),electricPower.Value()); } catch (Exception e) { - throw new VectoException(string.Format("WHR Map - Line {0}: {1}", data.Rows.IndexOf(row), e.Message), e); + throw new VectoException($"WHR Map - Line {data.Rows.IndexOf(row)}: {e.Message}", e); } } diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/AbstractSimulationDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/AbstractSimulationDataAdapter.cs index 04212c7685150d47348b492865bbc3c2fd924cba..e57bba31347a7a553c5692b4d80e76953d2df729 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/AbstractSimulationDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/AbstractSimulationDataAdapter.cs @@ -176,10 +176,10 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter protected virtual TransmissionLossMap CreateGearLossMap(ITransmissionInputData gear, uint i, bool useEfficiencyFallback, VehicleCategory vehicleCategory, GearboxType gearboxType) { if (gear.LossMap != null) { - return TransmissionLossMapReader.Create(gear.LossMap, gear.Ratio, string.Format("Gear {0}", i + 1), true); + return TransmissionLossMapReader.Create(gear.LossMap, gear.Ratio, $"Gear {i + 1}", true); } if (useEfficiencyFallback) { - return TransmissionLossMapReader.Create(gear.Efficiency, gear.Ratio, string.Format("Gear {0}", i + 1)); + return TransmissionLossMapReader.Create(gear.Efficiency, gear.Ratio, $"Gear {i + 1}"); } throw new InvalidFileFormatException("Gear {0} LossMap missing.", i + 1); } @@ -203,7 +203,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter protected virtual void CretateTCFirstGearATPowerSplit(GearData gearData, uint i, ShiftPolygon shiftPolygon) { gearData.TorqueConverterRatio = 1; - gearData.TorqueConverterGearLossMap = TransmissionLossMapReader.Create(1, 1, string.Format("TCGear {0}", i + 1)); + gearData.TorqueConverterGearLossMap = TransmissionLossMapReader.Create(1, 1, $"TCGear {i + 1}"); gearData.TorqueConverterShiftPolygon = shiftPolygon; } diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterCompletedBusGeneric.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterCompletedBusGeneric.cs index 8ade80f4d3a16da911cd3be7bdb8fa70a840bd99..e96fd6c86edfcba667b4efb628b1425bb8cfe4d4 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterCompletedBusGeneric.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterCompletedBusGeneric.cs @@ -82,7 +82,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter { gearData.TorqueConverterRatio = 1; //gearData.TorqueConverterGearLossMap = TransmissionLossMapReader.Create(GearEfficiencyIndirectGear, 1, string.Format("TCGear {0}", i + 1)); - gearData.TorqueConverterGearLossMap = TransmissionLossMapReader.Create(1.0, 1, string.Format("TCGear {0}", i + 1)); + gearData.TorqueConverterGearLossMap = TransmissionLossMapReader.Create(1.0, 1, $"TCGear {i + 1}"); gearData.TorqueConverterShiftPolygon = shiftPolygon; } diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterSingleBus.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterSingleBus.cs index 89d2dfe882738dec51e5a33ae11136de6e70c8ee..7a122f0bdc5475bb6d01fc085556d96b61c8183b 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterSingleBus.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterSingleBus.cs @@ -54,7 +54,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter protected override TransmissionLossMap CreateGearLossMap(ITransmissionInputData gear, uint i, bool useEfficiencyFallback, VehicleCategory vehicleCategory, GearboxType gearboxType) { - return TransmissionLossMapReader.Create(gear.LossMap, gear.Ratio, string.Format("Gear {0}", i + 1), true); + return TransmissionLossMapReader.Create(gear.LossMap, gear.Ratio, $"Gear {i + 1}", true); } diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeHeavyLorryVectoRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeHeavyLorryVectoRunDataFactory.cs index ed8f4997fd56990b8fd3210baf6a0de5f85b92d0..59e4ecfa2ede18abc3b65b330aadbf2d157d1fb9 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeHeavyLorryVectoRunDataFactory.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeHeavyLorryVectoRunDataFactory.cs @@ -175,7 +175,7 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl DriverData = _driverdata, ExecutionMode = ExecutionMode.Declaration, JobName = InputDataProvider.JobInputData.JobName, - ModFileSuffix = (engineModes.Count > 1 ? string.Format("_EngineMode{0}_", modeIdx) : "") + loading.Key.ToString(), + ModFileSuffix = (engineModes.Count > 1 ? $"_EngineMode{modeIdx}_" : "") + loading.Key.ToString(), Report = Report, Mission = mission, PTO = mission.MissionType == MissionType.MunicipalUtility diff --git a/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/HVAC/M01Impl.cs b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/HVAC/M01Impl.cs index 0bbdf2139eb353914efe7d2fdcee668ebcf4b2f7..31bc643b5cb94d5b41ae2ac660166655c2164d80 100644 --- a/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/HVAC/M01Impl.cs +++ b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/HVAC/M01Impl.cs @@ -31,7 +31,7 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.HVAC } if (compressorGearEfficiency <= 0 || compressorGearEfficiency > 1) { - throw new ArgumentException(String.Format("Compressor Gear efficiency must be between {0} and {1}", 0, 1)); + throw new ArgumentException($"Compressor Gear efficiency must be between {0} and {1}"); } //'Assign diff --git a/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Pneumatics/M04Impl.cs b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Pneumatics/M04Impl.cs index eb96cda82e36fd14749bccf125cdca8ff2dddaa4..363a54f34b6bf7f73d0b08bafa05f13d843348f1 100644 --- a/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Pneumatics/M04Impl.cs +++ b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Pneumatics/M04Impl.cs @@ -34,7 +34,7 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Pneumati if (value < MinRatio || value > MaxRatio) { throw new ArgumentOutOfRangeException( "pulleyGearRatio", value, - string.Format("Invalid value, should be in the range {0} to {1}", MinRatio, MaxRatio)); + $"Invalid value, should be in the range {MinRatio} to {MaxRatio}"); } _pulleyGearRatio = value; @@ -48,7 +48,7 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Pneumati if (value < MinEff || value > MaxEff) { throw new ArgumentOutOfRangeException( "pulleyGearEfficiency", value, - String.Format("Invalid value, should be in the range {0} to {1}", MinEff, MaxEff) + $"Invalid value, should be in the range {MinEff} to {MaxEff}" ); } diff --git a/VectoCore/VectoCore/Models/BusAuxiliaries/Util/FilePathUtils.cs b/VectoCore/VectoCore/Models/BusAuxiliaries/Util/FilePathUtils.cs index 51bf8c60353030396b117e1f1ce7dc45e0cfde66..5fad6cf9d2015ff8720cc4c633e10317e4246d52 100644 --- a/VectoCore/VectoCore/Models/BusAuxiliaries/Util/FilePathUtils.cs +++ b/VectoCore/VectoCore/Models/BusAuxiliaries/Util/FilePathUtils.cs @@ -45,7 +45,7 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries.Util { // Extension Expected, but not match if (expectedExtension.Trim().Length > 0) { if (string.Compare(expectedExtension, detectedExtention, true) != 0) { - message = string.Format("The file extension type does not match the expected type of {0}", expectedExtension); + message = $"The file extension type does not match the expected type of {expectedExtension}"; return false; } } @@ -53,7 +53,7 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries.Util { // Extension Not Expected, but was supplied if (expectedExtension.Trim().Length > 0) { if (detectedExtention.Length == 0) { - message = string.Format("No Extension was supplied, but an extension of {0}, this is not required", detectedExtention); + message = $"No Extension was supplied, but an extension of {detectedExtention}, this is not required"; return false; } } diff --git a/VectoCore/VectoCore/Models/Connector/Ports/Impl/BatteryResponse.cs b/VectoCore/VectoCore/Models/Connector/Ports/Impl/BatteryResponse.cs index 055f5352800abfb8b7b9d1a7528b605c41bbaf21..9c9675d60b1d65d6307e275f1fb3efd95b45a7c0 100644 --- a/VectoCore/VectoCore/Models/Connector/Ports/Impl/BatteryResponse.cs +++ b/VectoCore/VectoCore/Models/Connector/Ports/Impl/BatteryResponse.cs @@ -89,8 +89,7 @@ namespace TUGraz.VectoCore.Models.Connector.Ports.Impl public override string ToString() { var t = GetType(); - return string.Format("{0}{{{1}}}", t.Name, - string.Join(", ", t.GetProperties().Select(p => string.Format("{0}: {1}", p.Name, p.GetValue(this))))); + return $"{t.Name}{{{string.Join(", ", t.GetProperties().Select(p => $"{p.Name}: {p.GetValue(this)}"))}}}"; } } diff --git a/VectoCore/VectoCore/Models/Connector/Ports/Impl/Response.cs b/VectoCore/VectoCore/Models/Connector/Ports/Impl/Response.cs index 3f0d3bf899b3a5f97a4bb3c026f8aeb6d3a6a799..629cbeff730662d71ffd6d83286734172822603a 100644 --- a/VectoCore/VectoCore/Models/Connector/Ports/Impl/Response.cs +++ b/VectoCore/VectoCore/Models/Connector/Ports/Impl/Response.cs @@ -110,8 +110,7 @@ namespace TUGraz.VectoCore.Models.Connector.Ports.Impl public override string ToString() { var t = GetType(); - return string.Format("{0}{{{1}}}", t.Name, - string.Join(", ", t.GetProperties().Select(p => string.Format("{0}: {1}", p.Name, p.GetValue(this))))); + return $"{t.Name}{{{string.Join(", ", t.GetProperties().Select(p => $"{p.Name}: {p.GetValue(this)}"))}}}"; } } diff --git a/VectoCore/VectoCore/Models/Declaration/Axle.cs b/VectoCore/VectoCore/Models/Declaration/Axle.cs index 88f73bee3071650f806f1b5f067fb9e8b7c3dcc6..e6c99bff9ae9c45c1e856efa9849345b508bdf11 100644 --- a/VectoCore/VectoCore/Models/Declaration/Axle.cs +++ b/VectoCore/VectoCore/Models/Declaration/Axle.cs @@ -69,7 +69,7 @@ namespace TUGraz.VectoCore.Models.Declaration try { DeclarationData.Wheels.Lookup(axle.WheelsDimension); } catch (Exception) { - return new ValidationResult(string.Format("Unknown Tyre dimenstion '{0}'", axle.WheelsDimension)); + return new ValidationResult($"Unknown Tyre dimenstion '{axle.WheelsDimension}'"); } return ValidationResult.Success; } diff --git a/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs b/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs index 8ae43c859128612d34340b785f47be98ade37292..e8287a62cd6faa9417d403e2e07b79934affe74d 100644 --- a/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs +++ b/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs @@ -183,7 +183,7 @@ namespace TUGraz.VectoCore.Models.Declaration case "Large Supply 2-stage": resource = "DEFAULT_3-Cylinder_2-Stage_598ccm.acmp"; break; - default: throw new ArgumentException(string.Format("unkown compressor size {0}", compressorSize), compressorSize); + default: throw new ArgumentException($"unkown compressor size {compressorSize}", compressorSize); } var dragCurveFactorClutch = 1.0; diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs b/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs index dff5b60c4d54549d159bf25f73463f9525f2e0ed..2d345091b64cb893ea30f4dbcd2fd1cf2435d73b 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs @@ -1011,7 +1011,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl //return new ATShiftStrategy(runData, container); default: throw new ArgumentOutOfRangeException("GearboxType", - string.Format("Unknown Gearbox Type {0}", runData.GearboxData.Type.ToString())); + $"Unknown Gearbox Type {runData.GearboxData.Type.ToString()}"); } } @@ -1020,8 +1020,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl x.Item2.Equals(shiftStrategy, StringComparison.InvariantCultureIgnoreCase)); if (selected == null) { throw new ArgumentOutOfRangeException("ShiftStrategy", - string.Format("Unknown Shiftstrategy {0} for Gearbox Type {1}", shiftStrategy, - runData.GearboxData.Type.ToString())); + $"Unknown Shiftstrategy {shiftStrategy} for Gearbox Type {runData.GearboxData.Type.ToString()}"); } runData.ShiftStrategy = selected.Item3; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/DrivingCycleData.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/DrivingCycleData.cs index cb64cfeac6d78d550a6b1710d51428d9f9323619..ead6520b54df8872e43876e02c015cb8df5488f4 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/DrivingCycleData.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/DrivingCycleData.cs @@ -114,7 +114,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data } } if (result.Any()) { - return new ValidationResult(string.Format("Validation of Cycle {0} failed", cycleData.Name), result); + return new ValidationResult($"Validation of Cycle {cycleData.Name} failed", result); } return ValidationResult.Success; } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/VehicleData.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/VehicleData.cs index 288df23b962c15809381207dc5f4919c1854e318..15969af8e60efee043a86847064d36973e718297 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/VehicleData.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/VehicleData.cs @@ -321,19 +321,17 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data var weightShareSum = vehicleData.AxleData.Sum(axle => axle.AxleWeightShare); if (!weightShareSum.IsEqual(1.0, 1E-10)) { return new ValidationResult( - string.Format("Sum of axle weight share is not 1! sum: {0}, difference: {1}", - weightShareSum, 1 - weightShareSum)); + $"Sum of axle weight share is not 1! sum: {weightShareSum}, difference: {1 - weightShareSum}"); } for (var i = 0; i < vehicleData.AxleData.Count; i++) { if (vehicleData.AxleData[i].TyreTestLoad.IsSmallerOrEqual(0)) { - return new ValidationResult(string.Format("Tyre test load (FzISO) for axle {0} must be greater than 0.", i)); + return new ValidationResult($"Tyre test load (FzISO) for axle {i} must be greater than 0."); } } if (vehicleData.TotalRollResistanceCoefficient <= 0) { return - new ValidationResult(string.Format("Total rolling resistance must be greater than 0! {0}", - vehicleData.TotalRollResistanceCoefficient)); + new ValidationResult($"Total rolling resistance must be greater than 0! {vehicleData.TotalRollResistanceCoefficient}"); } // total gvw is limited by max gvw (40t) @@ -355,8 +353,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data if (vehicleData.TotalVehicleMass > gvwTotal) { return new ValidationResult( - string.Format("Total Vehicle mass is greater than GrossVehicleMass! Mass: {0}, GVM: {1}", - vehicleData.TotalVehicleMass, gvwTotal)); + $"Total Vehicle mass is greater than GrossVehicleMass! Mass: {vehicleData.TotalVehicleMass}, GVM: {gvwTotal}"); } var numDrivenAxles = vehicleData._axleData.Count(x => x.AxleType == AxleType.VehicleDriven); diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs index 219dfb35141ef596909c8f9f1266ea182019b816..147ff66a56527180a26dd15521e313a311bc9436 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs @@ -1523,9 +1523,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public override string ToString() { - return string.Format( - "action: {0} @ {1} / {2}. trigger: {3} targetSpeed: {4}", Action, CoastingStartDistance, - BrakingStartDistance, TriggerDistance, NextTargetSpeed); + return $"action: {Action} @ {CoastingStartDistance} / {BrakingStartDistance}. trigger: {TriggerDistance} targetSpeed: {NextTargetSpeed}"; } } } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/GearRating.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/GearRating.cs index e99785a56ea814f1ff7d98aa1831a4d8e7840501..3ee8595ee4a39aa6be51b0ec7eea3576fe5c90e4 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/GearRating.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/GearRating.cs @@ -44,7 +44,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { public override string ToString() { - return string.Format("{0} / {1} ({2})", RatingCase, Rating, NumericValue); + return $"{RatingCase} / {Rating} ({NumericValue})"; } public int CompareTo(object obj) diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/IdleControllerSwitcher.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/IdleControllerSwitcher.cs index 646d0201a33a05e7aa3f941883e5d0e0cf6849ee..f5c45832c342e67ce2ac4dee01658e19d4c0d060 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/IdleControllerSwitcher.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/IdleControllerSwitcher.cs @@ -60,7 +60,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public IResponse Initialize(NewtonMeter outTorque, PerSecond outAngularVelocity) { - throw new InvalidOperationException(string.Format("{0} cannot initialize.", GetType().FullName)); + throw new InvalidOperationException($"{GetType().FullName} cannot initialize."); } public ITnOutPort RequestPort diff --git a/VectoCore/VectoCore/OutputData/FileIO/FileOutputWriter.cs b/VectoCore/VectoCore/OutputData/FileIO/FileOutputWriter.cs index 67a0a46ebe7193e463a3f3a5b1eecfae29fd2ccf..3c91014942a2f181346bf3c05c1e0e7d03e91fa6 100644 --- a/VectoCore/VectoCore/OutputData/FileIO/FileOutputWriter.cs +++ b/VectoCore/VectoCore/OutputData/FileIO/FileOutputWriter.cs @@ -79,9 +79,9 @@ namespace TUGraz.VectoCore.OutputData.FileIO { string modFileName; if (!string.IsNullOrWhiteSpace(cycleName) || !string.IsNullOrWhiteSpace(runSuffix)) { - modFileName = string.Format("{0}_{1}{2}{3}", runName, cycleName, runSuffix, Constants.FileExtensions.ModDataFile); + modFileName = $"{runName}_{cycleName}{runSuffix}{Constants.FileExtensions.ModDataFile}"; } else { - modFileName = string.Format("{0}{1}", runName, Constants.FileExtensions.ModDataFile); + modFileName = $"{runName}{Constants.FileExtensions.ModDataFile}"; } return Path.Combine(BasePath, string.Concat(modFileName.Split(Path.GetInvalidFileNameChars()))); diff --git a/VectoCore/VectoCore/OutputData/FileIO/ShiftPolygonExport.cs b/VectoCore/VectoCore/OutputData/FileIO/ShiftPolygonExport.cs index ad577d95d4c8710d36e4c889b7888c5fee6a9e80..350351d18ff29766c20dfab2494ac22c33d41dbc 100644 --- a/VectoCore/VectoCore/OutputData/FileIO/ShiftPolygonExport.cs +++ b/VectoCore/VectoCore/OutputData/FileIO/ShiftPolygonExport.cs @@ -69,12 +69,11 @@ namespace TUGraz.VectoCore.OutputData.FileIO sb.AppendLine("engine torque [Nm],downshift rpm [1/min],upshift rpm [1/min]"); foreach (var line in lines.Values) { if (line.DownShift == null) - sb.AppendLine(string.Format("{0},,{1:0.0000}", line.Torque.ToOutputFormat(), line.UpShift.AsRPM)); + sb.AppendLine($"{line.Torque.ToOutputFormat()},,{line.UpShift.AsRPM:0.0000}"); else if (line.UpShift == null) - sb.AppendLine(string.Format("{0},{1:0.0000},", line.Torque.ToOutputFormat(), line.DownShift.AsRPM)); + sb.AppendLine($"{line.Torque.ToOutputFormat()},{line.DownShift.AsRPM:0.0000},"); else - sb.AppendLine(string.Format("{0},{1:0.0000},{2:0.0000}", line.Torque.ToOutputFormat(), line.DownShift.AsRPM, - line.UpShift.AsRPM)); + sb.AppendLine($"{line.Torque.ToOutputFormat()},{line.DownShift.AsRPM:0.0000},{line.UpShift.AsRPM:0.0000}"); } File.WriteAllText(fileName, sb.ToString()); diff --git a/VectoCore/VectoCore/OutputData/ModalDataContainer.cs b/VectoCore/VectoCore/OutputData/ModalDataContainer.cs index 69b0902db8ddc8591f188e3247ca3a6c7ff6ced0..1267d1d2c6826df94fc68de87977c8cac5cca781 100644 --- a/VectoCore/VectoCore/OutputData/ModalDataContainer.cs +++ b/VectoCore/VectoCore/OutputData/ModalDataContainer.cs @@ -144,7 +144,7 @@ namespace TUGraz.VectoCore.OutputData var col = new DataColumn( fuels.Count == 1 && !multipleEngineModes ? fcCol.GetName() - : string.Format("{0}_{1}", fcCol.GetName(), entry.FuelType.GetLabel()), typeof(SI)) { + : $"{fcCol.GetName()}_{entry.FuelType.GetLabel()}", typeof(SI)) { Caption = string.Format(fcCol.GetCaption(), fuels.Count == 1 && !multipleEngineModes ? "" : "_" + entry.FuelType.GetLabel()) }; diff --git a/VectoCore/VectoCore/OutputData/SummaryDataContainer.cs b/VectoCore/VectoCore/OutputData/SummaryDataContainer.cs index 8f96e87f1b2c4c3d381baa7491721cd3277376b2..9b03857807ac2778228c4d8ebd2de75db3740682 100644 --- a/VectoCore/VectoCore/OutputData/SummaryDataContainer.cs +++ b/VectoCore/VectoCore/OutputData/SummaryDataContainer.cs @@ -286,7 +286,7 @@ namespace TUGraz.VectoCore.OutputData var row = GetResultRow(modData, runData); row[Fields.SORT] = jobNr * 1000 + runNr; - row[Fields.JOB] = string.Format("{0}-{1}", jobNr, runNr); //ReplaceNotAllowedCharacters(current); + row[Fields.JOB] = $"{jobNr}-{runNr}"; //ReplaceNotAllowedCharacters(current); row[Fields.INPUTFILE] = ReplaceNotAllowedCharacters(runData.JobName); row[Fields.CYCLE] = ReplaceNotAllowedCharacters(runData.Cycle.Name + Constants.FileExtensions.CycleFile); diff --git a/VectoCore/VectoCore/OutputData/XML/AbstractXMLManufacturerReport.cs b/VectoCore/VectoCore/OutputData/XML/AbstractXMLManufacturerReport.cs index 920521811ccf9fe1ca1e7da7da910299abe3c67e..cb7a0e1a59b73a61a402a03c5b20cb9238759edb 100644 --- a/VectoCore/VectoCore/OutputData/XML/AbstractXMLManufacturerReport.cs +++ b/VectoCore/VectoCore/OutputData/XML/AbstractXMLManufacturerReport.cs @@ -73,7 +73,7 @@ namespace TUGraz.VectoCore.OutputData.XML new XAttribute(XNamespace.Xmlns + "mrf", mrf), new XAttribute( xsi + "schemaLocation", - string.Format("{0} {1}/DEV/VectoOutputManufacturer.xsd", mrf, AbstractXMLWriter.SchemaLocationBaseUrl)), + $"{mrf} {AbstractXMLWriter.SchemaLocationBaseUrl}/DEV/VectoOutputManufacturer.xsd"), new XElement( mrf + XMLNames.Report_DataWrap, new XAttribute(xsi + "type", "VectoOutputDataType"), @@ -124,7 +124,7 @@ namespace TUGraz.VectoCore.OutputData.XML GetSimulationParameters(resultEntry), new XElement( tns + XMLNames.Report_Results_Error, - string.Format("Simulation not finished! Status: {0}", resultEntry.Status)), + $"Simulation not finished! Status: {resultEntry.Status}"), new XElement(tns + XMLNames.Report_Results_ErrorDetails, ""), }; // should not happen! break; @@ -257,7 +257,7 @@ namespace TUGraz.VectoCore.OutputData.XML return new XElement( tns + XMLNames.Vehicle_ADAS, new XAttribute(XNamespace.Xmlns + adasPrefix, ns.NamespaceName), - new XAttribute(xsi + "type", string.Format("{0}:{1}", adasPrefix, type)), + new XAttribute(xsi + "type", $"{adasPrefix}:{type}"), XElement.Parse(adasData.InputData.XMLSource.OuterXml).Elements() ); } @@ -271,7 +271,7 @@ namespace TUGraz.VectoCore.OutputData.XML return new XElement( tns + XMLNames.Vehicle_ADAS, new XAttribute(XNamespace.Xmlns + adasPrefix, ns.NamespaceName), - new XAttribute(xsi + "type", string.Format("{0}:{1}", adasPrefix, type)), + new XAttribute(xsi + "type", $"{adasPrefix}:{type}"), new XElement(ns + XMLNames.Vehicle_ADAS_EngineStopStart, adasData.EngineStopStart), new XElement(ns + XMLNames.Vehicle_ADAS_EcoRollWithoutEngineStop, adasData.EcoRoll.WithoutEngineStop()), new XElement(ns + XMLNames.Vehicle_ADAS_EcoRollWithEngineStopStart, adasData.EcoRoll.WithEngineStop()), diff --git a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/AbstractComponentWriter.cs b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/AbstractComponentWriter.cs index d6b1ec151d21f23e34a7bcdbb0e2d5f6d670be65..0edfa0a73b0bbabf8b4fd39718531bd29b0fd22a 100644 --- a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/AbstractComponentWriter.cs +++ b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/AbstractComponentWriter.cs @@ -165,7 +165,7 @@ namespace TUGraz.VectoCore.OutputData.XML.Engineering.Writer { var xsns = Writer.RegisterNamespace(XMLDefinitions.XML_SCHEMA_NAMESPACE); return new XAttribute( - xsns + "type", string.Format("{0}:{1}", Writer.GetNSPrefix(ComponentDataNamespace.NamespaceName), XMLDataType)); + xsns + "type", $"{Writer.GetNSPrefix(ComponentDataNamespace.NamespaceName)}:{XMLDataType}"); } public virtual object[] WriteXML(IAdvancedDriverAssistantSystemsEngineering inputData) diff --git a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringAirdragWriter.cs b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringAirdragWriter.cs index 302bbe84ba83c877c07eee03d265b33a3faf6465..3857558bdac267daa3b7652a9d3930c7e943e04a 100644 --- a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringAirdragWriter.cs +++ b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringAirdragWriter.cs @@ -60,7 +60,7 @@ namespace TUGraz.VectoCore.OutputData.XML.Engineering.Writer protected override object[] DoWriteXML(IAirdragEngineeringInputData data) { var tns = ComponentDataNamespace; - var id = string.Format("Airdrag-{0}", data.Model); + var id = $"Airdrag-{data.Model}"; return new object[] { new XAttribute(XMLNames.Component_ID_Attr, id), GetXMLTypeAttribute(), diff --git a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringAngledriveWriter.cs b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringAngledriveWriter.cs index 1d47e0b614fa1a55122b2d673af1e5091baed0d5..f620cb4df36e6e907195a238f87ccc370ab2771f 100644 --- a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringAngledriveWriter.cs +++ b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringAngledriveWriter.cs @@ -60,7 +60,7 @@ namespace TUGraz.VectoCore.OutputData.XML.Engineering.Writer protected override object[] DoWriteXML(IAngledriveInputData data) { var tns = ComponentDataNamespace; - var typeId = string.Format("ANGLDRV-{0:0.000}", data.Ratio); + var typeId = $"ANGLDRV-{data.Ratio:0.000}"; return new object[] { GetXMLTypeAttribute(), new XAttribute(XMLNames.Component_ID_Attr, typeId), diff --git a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringAxlegearWriter.cs b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringAxlegearWriter.cs index ea4c2d91ecbf189be20279e124be6cafaddd4d66..9f702fd8c556fda0498c8c97224c6f3906d395cc 100644 --- a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringAxlegearWriter.cs +++ b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringAxlegearWriter.cs @@ -60,7 +60,7 @@ namespace TUGraz.VectoCore.OutputData.XML.Engineering.Writer protected override object[] DoWriteXML(IAxleGearInputData data) { var tns = ComponentDataNamespace; - var typeId = string.Format("AXLGEAR-{0:0.000}", data.Ratio); + var typeId = $"AXLGEAR-{data.Ratio:0.000}"; return new object[] { GetXMLTypeAttribute(), new XAttribute(XMLNames.Component_ID_Attr, typeId), diff --git a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringEngineWriter.cs b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringEngineWriter.cs index 084bcd4943d35ae646ce0828a063a7d1665ef9ee..f1dfa6e7bb660b3c1b65362cf9c130124233fbda 100644 --- a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringEngineWriter.cs +++ b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringEngineWriter.cs @@ -78,7 +78,7 @@ namespace TUGraz.VectoCore.OutputData.XML.Engineering.Writer } var filename = Path.Combine( - Writer.Configuration.BasePath, Writer.RemoveInvalidFileCharacters(string.Format("ENG_{0}.vfld", data.Model))); + Writer.Configuration.BasePath, Writer.RemoveInvalidFileCharacters($"ENG_{data.Model}.vfld")); return ExtCSVResource(data.EngineModes.First().FullLoadCurve, filename); } @@ -89,7 +89,7 @@ namespace TUGraz.VectoCore.OutputData.XML.Engineering.Writer } var filename = Path.Combine( - Writer.Configuration.BasePath, Writer.RemoveInvalidFileCharacters(string.Format("ENG_{0}.vmap", data.Model))); + Writer.Configuration.BasePath, Writer.RemoveInvalidFileCharacters($"ENG_{data.Model}.vmap")); return ExtCSVResource(data.EngineModes.First().Fuels.First().FuelConsumptionMap, filename); } diff --git a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringGearboxWriter.cs b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringGearboxWriter.cs index 98ece6cfb4c17b0e738060565aee66d4b09b1023..c18c1cf15f778a25597a6c96f94378c9c02145f0 100644 --- a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringGearboxWriter.cs +++ b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringGearboxWriter.cs @@ -70,7 +70,7 @@ namespace TUGraz.VectoCore.OutputData.XML.Engineering.Writer return new object[] { GetXMLTypeAttribute(), - new XAttribute(XMLNames.Component_ID_Attr, string.Format("GBX-{0}", data.Model)), + new XAttribute(XMLNames.Component_ID_Attr, $"GBX-{data.Model}"), GetDefaultComponentElements(data), new XElement(tns + XMLNames.Gearbox_TransmissionType, data.Type.ToXMLFormat()), diff --git a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringRetarderWriter.cs b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringRetarderWriter.cs index f0d94281d473759e90d3203bede0354b263eb179..0193ad06a5058d3a2da3a874702b3511c0304684 100644 --- a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringRetarderWriter.cs +++ b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringRetarderWriter.cs @@ -70,7 +70,7 @@ namespace TUGraz.VectoCore.OutputData.XML.Engineering.Writer data.LossMap, Path.Combine( Writer.Configuration.BasePath, - Writer.RemoveInvalidFileCharacters(string.Format("RET_{0}.vrlm", data.Model))))) + Writer.RemoveInvalidFileCharacters($"RET_{data.Model}.vrlm")))) }; return retarder; } diff --git a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringTorqueconverterWriter.cs b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringTorqueconverterWriter.cs index 0203c136e1cc12d152fa02451e54fa410e4947dc..471d6934a6f7b883964b201cc5a9cd743fe0ca49 100644 --- a/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringTorqueconverterWriter.cs +++ b/VectoCore/VectoCore/OutputData/XML/Engineering/Writer/XMLEngineeringTorqueconverterWriter.cs @@ -64,7 +64,7 @@ namespace TUGraz.VectoCore.OutputData.XML.Engineering.Writer var tns = ComponentDataNamespace; return new object[] { GetXMLTypeAttribute(), - new XAttribute(XMLNames.Component_ID_Attr, string.Format("TC-{0}", data.Model)), + new XAttribute(XMLNames.Component_ID_Attr, $"TC-{data.Model}"), GetDefaultComponentElements(data), new XElement(tns + XMLNames.TorqueConverter_ReferenceRPM, data.ReferenceRPM.AsRPM.ToXMLFormat()), new XElement( diff --git a/VectoCore/VectoCore/OutputData/XML/Engineering/XMLEngineeringWriter.cs b/VectoCore/VectoCore/OutputData/XML/Engineering/XMLEngineeringWriter.cs index d28c8e218ee971c9f5e80571de3eff007f7918be..2b64351e407fc565ac06a73d990135fb5cf01e59 100644 --- a/VectoCore/VectoCore/OutputData/XML/Engineering/XMLEngineeringWriter.cs +++ b/VectoCore/VectoCore/OutputData/XML/Engineering/XMLEngineeringWriter.cs @@ -113,7 +113,7 @@ namespace TUGraz.VectoCore.OutputData.XML.Engineering new XElement( v10Inp + XMLNames.VectoComponentEngineering, new XAttribute( - xsns + "type", string.Format("{0}:VectoComponentEngineeringType", GetNSPrefix(v10Def.NamespaceName))), + xsns + "type", $"{GetNSPrefix(v10Def.NamespaceName)}:VectoComponentEngineeringType"), GetNamespaceAttributes(), GetSchemaLocations(), new XElement( diff --git a/VectoCore/VectoCore/OutputData/XML/XMLCustomerReport.cs b/VectoCore/VectoCore/OutputData/XML/XMLCustomerReport.cs index 7f3224de4d1eb39ec16adee55e5b8e057a41157f..21fe09bb6f0dea0c6ef1de9f6e10038fcf8e3714 100644 --- a/VectoCore/VectoCore/OutputData/XML/XMLCustomerReport.cs +++ b/VectoCore/VectoCore/OutputData/XML/XMLCustomerReport.cs @@ -273,7 +273,7 @@ namespace TUGraz.VectoCore.OutputData.XML new XAttribute(XNamespace.Xmlns + "tns", rootNS), new XAttribute(XNamespace.Xmlns + "di", di), new XAttribute(xsi + "schemaLocation", - string.Format("{0} {1}DEV/VectoOutputCustomer.xsd", rootNS, AbstractXMLWriter.SchemaLocationBaseUrl)), + $"{rootNS} {AbstractXMLWriter.SchemaLocationBaseUrl}DEV/VectoOutputCustomer.xsd"), new XElement(rootNS + XMLNames.Report_DataWrap, new XAttribute(xsi + "type", "VectoOutputDataType"), vehicle, diff --git a/VectoCore/VectoCore/OutputData/XML/XMLCustomerReportCompletedBus.cs b/VectoCore/VectoCore/OutputData/XML/XMLCustomerReportCompletedBus.cs index 5118d89ea6bf966dcaf84632242f08315bd98bd1..735b0cb2f571cdffa1e7c176e273b902b1d49abe 100644 --- a/VectoCore/VectoCore/OutputData/XML/XMLCustomerReportCompletedBus.cs +++ b/VectoCore/VectoCore/OutputData/XML/XMLCustomerReportCompletedBus.cs @@ -100,7 +100,7 @@ namespace TUGraz.VectoCore.OutputData.XML { content = new object[] { new XElement( tns + XMLNames.Report_Results_Error, - string.Format("Simulation not finished! Status: {0} / {1}", genericResult.Status, specificResult.Status)), + $"Simulation not finished! Status: {genericResult.Status} / {specificResult.Status}"), new XElement(tns + XMLNames.Report_Results_ErrorDetails, ""), }; // should not happen! } @@ -283,7 +283,7 @@ namespace TUGraz.VectoCore.OutputData.XML { new XAttribute(XNamespace.Xmlns + "tns", rootNS), new XAttribute(XNamespace.Xmlns + "di", di), new XAttribute(xsi + "schemaLocation", - string.Format("{0} {1}DEV/VectoOutputCustomer.xsd", rootNS, AbstractXMLWriter.SchemaLocationBaseUrl)), + $"{rootNS} {AbstractXMLWriter.SchemaLocationBaseUrl}DEV/VectoOutputCustomer.xsd"), new XElement(rootNS + XMLNames.Report_DataWrap, new XAttribute(xsi + "type", "VectoOutputDataType"), vehicle, diff --git a/VectoCore/VectoCore/OutputData/XML/XMLDeclarationWriter.cs b/VectoCore/VectoCore/OutputData/XML/XMLDeclarationWriter.cs index 61f482c9d31cc96e2a2feb0aec955eb7039a4b72..6da3b15672a4cbe14e3c19cfac6d32317fd8381e 100644 --- a/VectoCore/VectoCore/OutputData/XML/XMLDeclarationWriter.cs +++ b/VectoCore/VectoCore/OutputData/XML/XMLDeclarationWriter.cs @@ -75,7 +75,7 @@ namespace TUGraz.VectoCore.OutputData.XML new XAttribute("xmlns", tns), new XAttribute(XNamespace.Xmlns + "tns", rootNamespace), new XAttribute(xsi + "schemaLocation", - string.Format("{0} {1}VectoInput.xsd", rootNamespace, SchemaLocationBaseUrl)), + $"{rootNamespace} {SchemaLocationBaseUrl}VectoInput.xsd"), CreateDeclarationJob(data)) ); return job; @@ -102,7 +102,7 @@ namespace TUGraz.VectoCore.OutputData.XML new XAttribute("xmlns", tns), new XAttribute(XNamespace.Xmlns + "tns", componentNamespace), new XAttribute(xsi + "schemaLocation", - string.Format("{0} {1}VectoComponent.xsd", componentNamespace, SchemaLocationBaseUrl)), + $"{componentNamespace} {SchemaLocationBaseUrl}VectoComponent.xsd"), content) ); return component; @@ -171,13 +171,13 @@ namespace TUGraz.VectoCore.OutputData.XML protected XElement CreateEngine(IEngineDeclarationInputData data, XNamespace ns = null) { - var id = CreateIdString(string.Format("ENG-{0}", data.Model.RemoveWhitespace())); + var id = CreateIdString($"ENG-{data.Model.RemoveWhitespace()}"); var fld = FullLoadCurveReader.Create(data.EngineModes.First().FullLoadCurve, true); return new XElement((ns ?? tns) + XMLNames.Component_Engine, new XElement(tns + XMLNames.ComponentDataWrapper, new XAttribute(XMLNames.Component_ID_Attr, id), - GetDefaultComponentElements(string.Format("ENG-{0}", data.Model), data.Model), + GetDefaultComponentElements($"ENG-{data.Model}", data.Model), new XElement(tns + XMLNames.Engine_Displacement, (data.Displacement.Value() * 1000 * 1000).ToXMLFormat(0)), new XElement(tns + XMLNames.Engine_IdlingSpeed, data.EngineModes.First().IdleSpeed.AsRPM.ToXMLFormat(0)), new XElement(tns + XMLNames.Engine_RatedSpeed, fld.RatedSpeed.AsRPM.ToXMLFormat(0)), @@ -220,13 +220,13 @@ namespace TUGraz.VectoCore.OutputData.XML ); gears.Add(gear); } - var id = CreateIdString(string.Format("GBX-{0}", gbxData.Model.RemoveWhitespace())); + var id = CreateIdString($"GBX-{gbxData.Model.RemoveWhitespace()}"); return new XElement((ns ?? tns) + XMLNames.Component_Gearbox, new XElement(tns + XMLNames.ComponentDataWrapper, new XAttribute(XMLNames.Component_ID_Attr, id), - GetDefaultComponentElements(string.Format("GBX-{0}", gbxData.Model), gbxData.Model), + GetDefaultComponentElements($"GBX-{gbxData.Model}", gbxData.Model), new XElement(tns + XMLNames.Gearbox_TransmissionType, gbxData.Type.ToXMLFormat()), new XElement(tns + XMLNames.Component_Gearbox_CertificationMethod, "Standard values"), gears @@ -242,7 +242,7 @@ namespace TUGraz.VectoCore.OutputData.XML throw new Exception("Torque Converter is required!"); } - var id = CreateIdString(string.Format("TC-{0}", data.Model.RemoveWhitespace())); + var id = CreateIdString($"TC-{data.Model.RemoveWhitespace()}"); return new XElement(tns + XMLNames.Component_TorqueConverter, @@ -262,7 +262,7 @@ namespace TUGraz.VectoCore.OutputData.XML private XElement CreateAngleDrive(IAngledriveInputData data, XNamespace ns = null) { - var id = CreateIdString(string.Format("ANGL-{0}", data.Model.RemoveWhitespace())); + var id = CreateIdString($"ANGL-{data.Model.RemoveWhitespace()}"); return new XElement((ns ?? tns) + XMLNames.Component_Angledrive, new XElement(tns + XMLNames.ComponentDataWrapper, @@ -277,7 +277,7 @@ namespace TUGraz.VectoCore.OutputData.XML public XElement CreateRetarder(IRetarderInputData data, XNamespace ns = null) { - var id = CreateIdString(string.Format("RET-{0}", data.Model.RemoveWhitespace())); + var id = CreateIdString($"RET-{data.Model.RemoveWhitespace()}"); return new XElement((ns ?? tns) + XMLNames.Component_Retarder, new XElement(tns + XMLNames.ComponentDataWrapper, @@ -294,7 +294,7 @@ namespace TUGraz.VectoCore.OutputData.XML public XElement CreateAxlegear(IAxleGearInputData data, XNamespace ns = null) { - var typeId = CreateIdString(string.Format("AXLGEAR-{0}", data.Ratio.ToString("F3", CultureInfo.InvariantCulture))); + var typeId = CreateIdString($"AXLGEAR-{data.Ratio.ToString("F3", CultureInfo.InvariantCulture)}"); return new XElement((ns ?? tns) + XMLNames.Component_Axlegear, new XElement(tns + XMLNames.ComponentDataWrapper, @@ -334,12 +334,12 @@ namespace TUGraz.VectoCore.OutputData.XML private XElement CreateTyre(ITyreDeclarationInputData tyre) { - var id = CreateIdString(string.Format("TYRE-{0}", tyre.Dimension).Replace("/", "_")); + var id = CreateIdString($"TYRE-{tyre.Dimension}".Replace("/", "_")); return new XElement(tns + "Tyre", new XElement(tns + XMLNames.ComponentDataWrapper, new XAttribute(XMLNames.Component_ID_Attr, id), - GetDefaultComponentElements(string.Format("TYRE-{0}", tyre.Dimension), tyre.Dimension), + GetDefaultComponentElements($"TYRE-{tyre.Dimension}", tyre.Dimension), new XElement(tns + XMLNames.AxleWheels_Axles_Axle_Dimension, tyre.Dimension), new XElement(tns + XMLNames.AxleWheels_Axles_Axle_RRCDeclared, tyre.RollResistanceCoefficient.ToXMLFormat(4)), new XElement(tns + XMLNames.AxleWheels_Axles_Axle_FzISO, tyre.TyreTestLoad.Value().ToXMLFormat(0)) @@ -369,7 +369,7 @@ namespace TUGraz.VectoCore.OutputData.XML private XElement CreateAirdrag(IAirdragDeclarationInputData data, XNamespace ns = null) { - var id = CreateIdString(string.Format("Airdrag-{0}", data.Model)); + var id = CreateIdString($"Airdrag-{data.Model}"); return new XElement((ns ?? tns) + XMLNames.Component_AirDrag, new XElement(tns + XMLNames.ComponentDataWrapper, diff --git a/VectoCore/VectoCore/OutputData/XML/XMLManufacturerReportCompletedBus.cs b/VectoCore/VectoCore/OutputData/XML/XMLManufacturerReportCompletedBus.cs index 0144f8cfa034cd2c1c2aa3dc49a293b0473f328d..cd7913d111f4b0d351b50352cb99edfeb7e9de7f 100644 --- a/VectoCore/VectoCore/OutputData/XML/XMLManufacturerReportCompletedBus.cs +++ b/VectoCore/VectoCore/OutputData/XML/XMLManufacturerReportCompletedBus.cs @@ -98,7 +98,7 @@ namespace TUGraz.VectoCore.OutputData.XML { content = new object[] { new XElement( tns + XMLNames.Report_Results_Error, - string.Format("Simulation not finished! Status: {0} / {1}", genericResult.Status, specificResult.Status)), + $"Simulation not finished! Status: {genericResult.Status} / {specificResult.Status}"), new XElement(tns + XMLNames.Report_Results_ErrorDetails, ""), }; // should not happen! } @@ -387,7 +387,7 @@ namespace TUGraz.VectoCore.OutputData.XML { return new XElement( tns + XMLNames.Component_Auxiliaries, new XAttribute(XNamespace.Xmlns + auxPrefix, ns.NamespaceName), - new XAttribute(xsi + "type", string.Format("{0}:{1}", auxPrefix, busAuxXML.FirstChild.SchemaInfo.SchemaType.QualifiedName.Name)), + new XAttribute(xsi + "type", $"{auxPrefix}:{busAuxXML.FirstChild.SchemaInfo.SchemaType.QualifiedName.Name}"), XElement.Parse(busAuxXML.InnerXml).Elements() ); } diff --git a/VectoCore/VectoCore/OutputData/XML/XMLManufacturerReportPrimaryBus.cs b/VectoCore/VectoCore/OutputData/XML/XMLManufacturerReportPrimaryBus.cs index f1b62a28de21ca8620866c8eff7e573c2160194a..5720b3f3f9ed9211b19f283842878b363825ba99 100644 --- a/VectoCore/VectoCore/OutputData/XML/XMLManufacturerReportPrimaryBus.cs +++ b/VectoCore/VectoCore/OutputData/XML/XMLManufacturerReportPrimaryBus.cs @@ -63,7 +63,7 @@ namespace TUGraz.VectoCore.OutputData.XML { return new XElement( tns + XMLNames.Component_Auxiliaries, new XAttribute(XNamespace.Xmlns + auxPrefix, ns.NamespaceName), - new XAttribute(xsi + "type", string.Format("{0}:{1}", auxPrefix, busAuxXML.FirstChild.SchemaInfo.SchemaType.QualifiedName.Name)), + new XAttribute(xsi + "type", $"{auxPrefix}:{busAuxXML.FirstChild.SchemaInfo.SchemaType.QualifiedName.Name}"), XElement.Parse(busAuxXML.InnerXml).Elements() ); } diff --git a/VectoCore/VectoCore/OutputData/XML/XMLMonitoringReport.cs b/VectoCore/VectoCore/OutputData/XML/XMLMonitoringReport.cs index 73e03d54bde62c25920a290ba7c3f3d458a46333..47aff5e005b6e0810cc1341ea5252d9a7f39e0fe 100644 --- a/VectoCore/VectoCore/OutputData/XML/XMLMonitoringReport.cs +++ b/VectoCore/VectoCore/OutputData/XML/XMLMonitoringReport.cs @@ -93,7 +93,7 @@ namespace TUGraz.VectoCore.OutputData.XML new XAttribute(XNamespace.Xmlns + prefix, mrfType.Namespace), new XElement( tns + "ManufacturerRecord", - new XAttribute(xsi + "type", string.Format("{0}:{1}", prefix, mrfType.Name)), + new XAttribute(xsi + "type", $"{prefix}:{mrfType.Name}"), new XAttribute("xmlns", mrfType.Namespace), new XAttribute(XNamespace.Xmlns + "m", tns), GetManufacturerData(mrf)), @@ -133,8 +133,7 @@ namespace TUGraz.VectoCore.OutputData.XML new XAttribute(XNamespace.Xmlns + "di", di), new XAttribute( xsi + "schemaLocation", - string.Format( - "{0} {1}VectoMonitoring.xsd", NAMESPACE_BASE_URI, AbstractXMLWriter.SchemaLocationBaseUrl)) + $"{NAMESPACE_BASE_URI} {AbstractXMLWriter.SchemaLocationBaseUrl}VectoMonitoring.xsd") ) ); return retVal; @@ -147,7 +146,7 @@ namespace TUGraz.VectoCore.OutputData.XML for (var i = 0; i < axleData.Length; i++) { axleData[i] = new XElement(tns + "Axle", new XAttribute("axleNumber", i+1), - new XElement(tns + "Tyre", GetStandardFields(string.Format("TYRE_{0}", i+1)) + new XElement(tns + "Tyre", GetStandardFields($"TYRE_{i + 1}") )); } @@ -185,9 +184,9 @@ namespace TUGraz.VectoCore.OutputData.XML private object[] GetStandardFields(string prefix) { return new[] { - new XElement(tns + "Manufacturer", string.Format("##{0}_MANUFACTURER##", prefix)), - new XElement(tns + "ManufacturerAddress", string.Format("##{0}_MANUFACTURERADDRESS##", prefix)), - new XElement(tns + "Make", string.Format("##{0}_MAKE##", prefix)) + new XElement(tns + "Manufacturer", $"##{prefix}_MANUFACTURER##"), + new XElement(tns + "ManufacturerAddress", $"##{prefix}_MANUFACTURERADDRESS##"), + new XElement(tns + "Make", $"##{prefix}_MAKE##") }; } diff --git a/VectoCore/VectoCore/OutputData/XML/XMLPrimaryVehicleReport.cs b/VectoCore/VectoCore/OutputData/XML/XMLPrimaryVehicleReport.cs index 1f3a72425991957da71fba810e05e09fb421965b..8d7a69cbe730936ccba434e253431ccccd74a178 100644 --- a/VectoCore/VectoCore/OutputData/XML/XMLPrimaryVehicleReport.cs +++ b/VectoCore/VectoCore/OutputData/XML/XMLPrimaryVehicleReport.cs @@ -162,7 +162,7 @@ namespace TUGraz.VectoCore.OutputData.XML new XAttribute(XNamespace.Xmlns + adasPrefix, ns.NamespaceName), new XAttribute( xsi + "type", - string.Format("{0}:{1}", adasPrefix, adasData.InputData.XMLSource.SchemaInfo.SchemaType.QualifiedName.Name)), + $"{adasPrefix}:{adasData.InputData.XMLSource.SchemaInfo.SchemaType.QualifiedName.Name}"), XElement.Parse(adasData.InputData.XMLSource.OuterXml).Elements() ); } @@ -181,7 +181,7 @@ namespace TUGraz.VectoCore.OutputData.XML tns + XMLNames.Vehicle_TorqueLimits, new XAttribute(XNamespace.Xmlns + adasPrefix, ns.NamespaceName), new XAttribute( - xsi + "type", string.Format("{0}:{1}", adasPrefix, tcLimits.SchemaInfo.SchemaType.QualifiedName.Name)), + xsi + "type", $"{adasPrefix}:{tcLimits.SchemaInfo.SchemaType.QualifiedName.Name}"), XElement.Parse(tcLimits.OuterXml).Elements() ); } diff --git a/VectoCore/VectoCore/OutputData/XML/XMLVTPReport.cs b/VectoCore/VectoCore/OutputData/XML/XMLVTPReport.cs index c22ac6e1e0ba1ee2ed04b49be6548181ab8fac6c..bc8be65f48f25b261e84779a6c3413935c27ac33 100644 --- a/VectoCore/VectoCore/OutputData/XML/XMLVTPReport.cs +++ b/VectoCore/VectoCore/OutputData/XML/XMLVTPReport.cs @@ -293,7 +293,7 @@ namespace TUGraz.VectoCore.OutputData.XML tns + "CO2", new XElement( tns + "Mission", - string.Format("{0}, {1}", selectedMission.ToXMLFormat(), selectedLoading.ToString()) + $"{selectedMission.ToXMLFormat()}, {selectedLoading.ToString()}" ), new XElement( tns + "Declared", new XAttribute(XMLNames.Report_Results_Unit_Attr, key), @@ -328,7 +328,7 @@ namespace TUGraz.VectoCore.OutputData.XML //new XAttribute(XNamespace.Xmlns + "di", di), new XAttribute( xsi + "schemaLocation", - string.Format("{0} {1}VTPReport.xsd", rootNS, AbstractXMLWriter.SchemaLocationBaseUrl)), + $"{rootNS} {AbstractXMLWriter.SchemaLocationBaseUrl}VTPReport.xsd"), new XElement( rootNS + "Data", new XAttribute(xsi + "type", "VTPReportDataType"), @@ -442,7 +442,7 @@ namespace TUGraz.VectoCore.OutputData.XML bool status; var componentName = count == 1 ? VectoComponentsExtensionMethods.XMLElementName(component) - : string.Format("{0} ({1})", VectoComponentsExtensionMethods.XMLElementName(component), i + 1); + : $"{VectoComponentsExtensionMethods.XMLElementName(component)} ({i + 1})"; XElement retVal; try { var recomputed = InputDataHash.ComputeHash(component, i); diff --git a/VectoCore/VectoCore/Utils/DataIntegrityHelper.cs b/VectoCore/VectoCore/Utils/DataIntegrityHelper.cs index 93c1d55765927630424907ca0f9f2ffb91557260..edc9e98a1ea4aa3be9d37ae88e47430358216b33 100644 --- a/VectoCore/VectoCore/Utils/DataIntegrityHelper.cs +++ b/VectoCore/VectoCore/Utils/DataIntegrityHelper.cs @@ -40,7 +40,7 @@ namespace TUGraz.VectoCore.Utils { var hash = System.Convert.ToBase64String(GetHash(string.Join("\n", lines))); - return string.Format("SHA256: {0}", hash); + return $"SHA256: {hash}"; } public static byte[] GetHash(string inputString) diff --git a/VectoCore/VectoCore/Utils/DataTableExtensionMethods.cs b/VectoCore/VectoCore/Utils/DataTableExtensionMethods.cs index 2c2813ab4a3e0a4aed9a09315e06f409caffb105..3f99fb03af72be15ae21dc9110b373f2778a5015 100644 --- a/VectoCore/VectoCore/Utils/DataTableExtensionMethods.cs +++ b/VectoCore/VectoCore/Utils/DataTableExtensionMethods.cs @@ -69,7 +69,7 @@ namespace TUGraz.VectoCore.Utils public static double ParseDouble(this DataRow row, string columnName) { if (!row.Table.Columns.Contains(columnName)) { - throw new KeyNotFoundException(string.Format("Column {0} was not found in DataRow.", columnName)); + throw new KeyNotFoundException($"Column {columnName} was not found in DataRow."); } return row.ParseDouble(row.Table.Columns[columnName]); } @@ -79,27 +79,25 @@ namespace TUGraz.VectoCore.Utils try { return row.Field<string>(column).ToDouble(); } catch (IndexOutOfRangeException e) { - throw new VectoException(string.Format("Field {0} was not found in DataRow.", column), e); + throw new VectoException($"Field {column} was not found in DataRow.", e); } catch (NullReferenceException e) { - throw new VectoException(string.Format("Field {0} must not be null.", column), e); + throw new VectoException($"Field {column} must not be null.", e); } catch (FormatException e) { - throw new VectoException(string.Format("Field {0} is not in a valid number format: {1}", column, - row.Field<string>(column)), e); + throw new VectoException($"Field {column} is not in a valid number format: {row.Field<string>(column)}", e); } catch (OverflowException e) { - throw new VectoException(string.Format("Field {0} has a value too high or too low: {1}", column, - row.Field<string>(column)), e); + throw new VectoException($"Field {column} has a value too high or too low: {row.Field<string>(column)}", e); } catch (ArgumentNullException e) { - throw new VectoException(string.Format("Field {0} contains null which cannot be converted to a number.", column), + throw new VectoException($"Field {column} contains null which cannot be converted to a number.", e); } catch (Exception e) { - throw new VectoException(string.Format("Field {0}: {1}", column, e.Message), e); + throw new VectoException($"Field {column}: {e.Message}", e); } } public static bool ParseBoolean(this DataRow row, string columnName) { if (!row.Table.Columns.Contains(columnName)) { - throw new KeyNotFoundException(string.Format("Column {0} was not found in DataRow.", columnName)); + throw new KeyNotFoundException($"Column {columnName} was not found in DataRow."); } return row.Field<string>(row.Table.Columns[columnName]).ToBoolean(); } diff --git a/VectoCore/VectoCore/Utils/DelaunayMap.cs b/VectoCore/VectoCore/Utils/DelaunayMap.cs index 6fb478bb382398747380bdcce3bd1ac18f156f93..4ce3f5bd88b03e278c06ee2818f2f22ba3c95c48 100644 --- a/VectoCore/VectoCore/Utils/DelaunayMap.cs +++ b/VectoCore/VectoCore/Utils/DelaunayMap.cs @@ -92,8 +92,7 @@ namespace TUGraz.VectoCore.Utils public void Triangulate() { if (_points.Count < 3) { - throw new ArgumentException(string.Format("{0}: Triangulation needs at least 3 Points. Got {1} Points.", _mapName, - _points.Count)); + throw new ArgumentException($"{_mapName}: Triangulation needs at least 3 Points. Got {_points.Count} Points."); } SanitycheckInputPoints(); @@ -165,7 +164,7 @@ namespace TUGraz.VectoCore.Utils } if (duplicates.Any()) { throw new VectoException("{0}: Input Data for Delaunay map contains duplicates! \n{1}", _mapName, - string.Join("\n", duplicates.Select(pt => string.Format("{0} / {1}", pt.Key.X, pt.Key.Y)))); + string.Join("\n", duplicates.Select(pt => $"{pt.Key.X} / {pt.Key.Y}"))); } } @@ -225,7 +224,7 @@ namespace TUGraz.VectoCore.Utils var type = string.Join("", method.DeclaringType.Name.Split(Path.GetInvalidFileNameChars())); var methodName = string.Join("", method.Name.Split(Path.GetInvalidFileNameChars())); Directory.CreateDirectory("delaunay"); - chart.SaveImage(string.Format("delaunay\\{0}_{1}_{2}_{3}.png", type, methodName, superTriangle.GetHashCode(), i), + chart.SaveImage($"delaunay\\{type}_{methodName}_{superTriangle.GetHashCode()}_{i}.png", ChartImageFormat.Png); } } diff --git a/VectoCore/VectoCore/Utils/VectoCSVFile.cs b/VectoCore/VectoCore/Utils/VectoCSVFile.cs index f4ccae73c0676f9b1ce8c2884a8d0b9fd462cf10..3f7365d0fc95cf276aba44b21f9580f061a20ff5 100644 --- a/VectoCore/VectoCore/Utils/VectoCSVFile.cs +++ b/VectoCore/VectoCore/Utils/VectoCSVFile.cs @@ -164,7 +164,7 @@ namespace TUGraz.VectoCore.Utils table.Rows.Add(cells); } catch (InvalidCastException e) { throw new CSVReadException( - string.Format("Line {0}: The data format of a value is not correct. {1}", lineNumber, e.Message), e); + $"Line {lineNumber}: The data format of a value is not correct. {e.Message}", e); } lineNumber++; } @@ -240,7 +240,7 @@ namespace TUGraz.VectoCore.Utils // if a string contains a "," then it has to be contained in quotes in order to be correctly recognized in a CSV file. if (formattedList[i].Contains(Delimiter)) { - formattedList[i] = string.Format("\"{0}\"", formattedList[i]); + formattedList[i] = $"\"{formattedList[i]}\""; } } entries.Add(string.Join(Delimiter, formattedList)); @@ -248,7 +248,7 @@ namespace TUGraz.VectoCore.Utils if (addDigest) { var digest = DataIntegrityHelper.ComputeDigestValue(entries.Where(x => !x.StartsWith(DigestValuePrefix)).ToArray()); - entries.Add(string.Format("{0} {1}", DigestValuePrefix, digest)); + entries.Add($"{DigestValuePrefix} {digest}"); } foreach (var entry in entries) { diff --git a/VectoCore/VectoCore/Utils/XMLDefinitions.cs b/VectoCore/VectoCore/Utils/XMLDefinitions.cs index 65099861ac3093164a3c3b35dd9b2b17e84315d3..11957a048ac63fe8431f49af2336935d160b0638 100644 --- a/VectoCore/VectoCore/Utils/XMLDefinitions.cs +++ b/VectoCore/VectoCore/Utils/XMLDefinitions.cs @@ -141,7 +141,7 @@ namespace TUGraz.VectoCore.Utils public static string GetSchemaFilename(XmlDocumentType type) { if (!schemaFilenames.ContainsKey(type)) { - throw new Exception(string.Format("Invalid argument '{0}' - only use single flags", type)); + throw new Exception($"Invalid argument '{type}' - only use single flags"); } var entry = schemaFilenames[type]; diff --git a/VectoCore/VectoCore/Utils/XMLHelper.cs b/VectoCore/VectoCore/Utils/XMLHelper.cs index 4793725a250eb9d37507e1bf0a197c699666d7b9..49d6fff697cf95f5e99990f585ccfb94b57c375f 100644 --- a/VectoCore/VectoCore/Utils/XMLHelper.cs +++ b/VectoCore/VectoCore/Utils/XMLHelper.cs @@ -83,7 +83,7 @@ namespace TUGraz.VectoCore.Utils case "kg": return GetValueAsUnit(mass.Value(), unit, decimals); } - throw new NotImplementedException(string.Format("unknown unit '{0}'", unit)); + throw new NotImplementedException($"unknown unit '{unit}'"); } public static object[] ValueAsUnit(Watt power, string unit, uint? decimals = 0) @@ -93,7 +93,7 @@ namespace TUGraz.VectoCore.Utils case "W": return GetValueAsUnit(power?.Value(), unit, decimals); } - throw new NotImplementedException(string.Format("unknown unit '{0}'", unit)); + throw new NotImplementedException($"unknown unit '{unit}'"); } public static object[] ValueAsUnit(CubicMeter volume, string unit, uint? decimals = 0) @@ -104,7 +104,7 @@ namespace TUGraz.VectoCore.Utils case "m3": return GetValueAsUnit(volume.Value(), unit, decimals); } - throw new NotImplementedException(string.Format("unknown unit '{0}'", unit)); + throw new NotImplementedException($"unknown unit '{unit}'"); } public static object[] ValueAsUnit(PerSecond angSpeed, string unit, uint? decimals = 0) @@ -113,7 +113,7 @@ namespace TUGraz.VectoCore.Utils case "rpm": return GetValueAsUnit(angSpeed.ConvertToRoundsPerMinute(), unit, decimals); } - throw new NotImplementedException(string.Format("unknown unit '{0}'", unit)); + throw new NotImplementedException($"unknown unit '{unit}'"); } @@ -123,7 +123,7 @@ namespace TUGraz.VectoCore.Utils case "km/h": return GetValueAsUnit(speed.ConvertToKiloMeterPerHour(), unit, decimals); } - throw new NotImplementedException(string.Format("unknown unit '{0}'", unit)); + throw new NotImplementedException($"unknown unit '{unit}'"); } public static object[] ValueAsUnit(MeterPerSquareSecond acc, string unit, uint? decimals) @@ -132,7 +132,7 @@ namespace TUGraz.VectoCore.Utils case "m/s²": return GetValueAsUnit(acc.Value(), unit, decimals); } - throw new NotImplementedException(string.Format("unknown unit '{0}'", unit)); + throw new NotImplementedException($"unknown unit '{unit}'"); } public static object[] ValueAsUnit(Meter m, string unit, uint? decimals) @@ -142,7 +142,7 @@ namespace TUGraz.VectoCore.Utils case "km": return GetValueAsUnit(m.ConvertToKiloMeter(), unit, decimals); } - throw new NotImplementedException(string.Format("unknown unit '{0}'", unit)); + throw new NotImplementedException($"unknown unit '{unit}'"); } public static object[] ValueAsUnit(double value, string unit, uint? decimals) @@ -182,7 +182,7 @@ namespace TUGraz.VectoCore.Utils public static string QueryLocalName(string nodeName) { - return string.Format(".//*[local-name()='{0}']", nodeName); + return $".//*[local-name()='{nodeName}']"; } public static string QueryLocalName(params string[] nodePath) @@ -252,9 +252,7 @@ namespace TUGraz.VectoCore.Utils } private static string ExtCSVResourceQuery => - string.Format( - "/*[local-name()='{0}' and @{1}='{2}']", XMLNames.ExternalResource, XMLNames.ExtResource_Type_Attr, - XMLNames.ExtResource_Type_Value_CSV); + $"/*[local-name()='{XMLNames.ExternalResource}' and @{XMLNames.ExtResource_Type_Attr}='{XMLNames.ExtResource_Type_Value_CSV}']"; private static IEnumerable<T> Shim<T>(XmlNodeList nodes) { diff --git a/VectoCore/VectoCore/Utils/XMLValidator.cs b/VectoCore/VectoCore/Utils/XMLValidator.cs index 40bb4f8bfba89009be7ebc34c710d9a85b937017..171ed8772b3baeea63b863f310811f1637771336 100644 --- a/VectoCore/VectoCore/Utils/XMLValidator.cs +++ b/VectoCore/VectoCore/Utils/XMLValidator.cs @@ -122,7 +122,7 @@ namespace TUGraz.VectoCore.Utils resource = RessourceHelper.LoadResourceAsStream(RessourceHelper.ResourceType.XMLSchema, schemaFile); } catch (Exception e) { throw new Exception( - string.Format("Missing resource {0} for XML document type: {1} ({2})", schemaFile, entry, docType.ToString()), e); + $"Missing resource {schemaFile} for XML document type: {entry} ({docType.ToString()})", e); } var reader = XmlReader.Create(resource, new XmlReaderSettings(), "schema://"); diff --git a/VectoCore/VectoCore/Utils/XPathHelper.cs b/VectoCore/VectoCore/Utils/XPathHelper.cs index 85fbfe15b6485700b1f73ae5e682bd20e9b7e1bb..3f18f3a79d84279eaad183e20bb2807d41a899b2 100644 --- a/VectoCore/VectoCore/Utils/XPathHelper.cs +++ b/VectoCore/VectoCore/Utils/XPathHelper.cs @@ -67,7 +67,7 @@ namespace TUGraz.VectoCore.Utils public string QueryAbs(params string[] xPathSections) { - return string.Format("/{0}", Query(xPathSections)); + return $"/{Query(xPathSections)}"; } public string NSPrefix(string element, string prefix = null) diff --git a/VectoCore/VectoCoreTest/Algorithms/CSVDigestValueTest.cs b/VectoCore/VectoCoreTest/Algorithms/CSVDigestValueTest.cs index 97bf4aa707007a0c739b7407469e29d9da5b53d4..e9e38942fe7cb721ed8b76f7815cf5333668b559 100644 --- a/VectoCore/VectoCoreTest/Algorithms/CSVDigestValueTest.cs +++ b/VectoCore/VectoCoreTest/Algorithms/CSVDigestValueTest.cs @@ -95,7 +95,7 @@ namespace TUGraz.VectoCore.Tests.Algorithms var digest = DataIntegrityHelper.ComputeDigestValue(otherLines); - Assert.AreEqual(string.Format("#@ {0}", digest), last); + Assert.AreEqual($"#@ {digest}", last); } private static DataTable CreateDataTable(string[] cols, int numRows) diff --git a/VectoCore/VectoCoreTest/Algorithms/DelaunayMapTest.cs b/VectoCore/VectoCoreTest/Algorithms/DelaunayMapTest.cs index bdefb58d3776418d6e417da3f258a0c9f6d6e380..e6017218e5fa8c835f64c2b1fed8c83ee0bacf1b 100644 --- a/VectoCore/VectoCoreTest/Algorithms/DelaunayMapTest.cs +++ b/VectoCore/VectoCoreTest/Algorithms/DelaunayMapTest.cs @@ -215,7 +215,7 @@ namespace TUGraz.VectoCore.Tests.Algorithms // test one arbitrary point in the middle AssertHelper.AreRelativeEqual(37681, map.Interpolate(1500 * xfactor, 1300 * yfactor), - string.Format("{0}, {1}", xfactor, yfactor)); + $"{xfactor}, {yfactor}"); } } } diff --git a/VectoCore/VectoCoreTest/Integration/ATPowerTrain.cs b/VectoCore/VectoCoreTest/Integration/ATPowerTrain.cs index b09819ddd799604af482b2480749f1637b73f6bd..233f680a270f56edd738389a6561a52a0db004c3 100644 --- a/VectoCore/VectoCoreTest/Integration/ATPowerTrain.cs +++ b/VectoCore/VectoCoreTest/Integration/ATPowerTrain.cs @@ -151,14 +151,14 @@ namespace TUGraz.VectoCore.Tests.Integration new GearData { //MaxTorque = 2300.SI<NewtonMeter>(), LossMap = ratio.IsEqual(1) - ? TransmissionLossMapReader.Create(0.96, ratio, string.Format("Gear {0}", i)) - : TransmissionLossMapReader.Create(0.98, ratio, string.Format("Gear {0}", i)), + ? TransmissionLossMapReader.Create(0.96, ratio, $"Gear {i}") + : TransmissionLossMapReader.Create(0.98, ratio, $"Gear {i}"), Ratio = ratio, ShiftPolygon = ShiftPolygonReader.ReadFromFile(GearboxShiftPolygonFile), TorqueConverterRatio = i == 0 ? (gbxType == GearboxType.ATPowerSplit ? 1.0 : ratio) : double.NaN, TorqueConverterGearLossMap = i == 0 ? TransmissionLossMapReader.Create(gbxType == GearboxType.ATPowerSplit ? 1.0 : 0.98, ratio, - string.Format("Gear {0}", i)) + $"Gear {i}") : null, TorqueConverterShiftPolygon = i == 0 ? ShiftPolygonReader.ReadFromFile(GearboxShiftPolygonFile) : null })) diff --git a/VectoCore/VectoCoreTest/Integration/BatteryElectric/BatteryElectricTest.cs b/VectoCore/VectoCoreTest/Integration/BatteryElectric/BatteryElectricTest.cs index e7bf57aefb9d1a1f4dae78382f80fee9527143eb..9ae61f5b293ab54767a8b3c250aeba21cbdf5c08 100644 --- a/VectoCore/VectoCoreTest/Integration/BatteryElectric/BatteryElectricTest.cs +++ b/VectoCore/VectoCoreTest/Integration/BatteryElectric/BatteryElectricTest.cs @@ -113,7 +113,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BatteryElectric const bool largeMotor = true; - var modFilename = string.Format("SimpleBatteryElectric-B4_constant_{0}-{1}_{2}_{3}", vmax, initialSoC, slope, pAuxEl); + var modFilename = $"SimpleBatteryElectric-B4_constant_{vmax}-{initialSoC}_{slope}_{pAuxEl}"; const PowertrainPosition pos = PowertrainPosition.BatteryElectricE4; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 2, 22.6, largeMotor: true, pAuxEl: pAuxEl); @@ -149,7 +149,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BatteryElectric const bool largeMotor = true; - var modFilename = string.Format("SimpleBatteryElectric-B4_acc_{0}-{1}_{2}", vmax, initialSoC, slope); + var modFilename = $"SimpleBatteryElectric-B4_acc_{vmax}-{initialSoC}_{slope}"; const PowertrainPosition pos = PowertrainPosition.BatteryElectricE4; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 2, 22.6, largeMotor: true); @@ -185,7 +185,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BatteryElectric const bool largeMotor = true; - var modFilename = string.Format("SimpleParallelHybrid-B4_cycle_{0}-{1}_{2}_{3}", declarationMission, initialSoC, payload, pAuxEl); + var modFilename = $"SimpleParallelHybrid-B4_cycle_{declarationMission}-{initialSoC}_{payload}_{pAuxEl}"; const PowertrainPosition pos = PowertrainPosition.BatteryElectricE4; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 2, 22.6, largeMotor: true); @@ -270,7 +270,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BatteryElectric const bool largeMotor = true; - var modFilename = string.Format("SimpleBatteryElectric-B3_constant_{0}-{1}_{2}_{3}", vmax, initialSoC, slope, pAuxEl); + var modFilename = $"SimpleBatteryElectric-B3_constant_{vmax}-{initialSoC}_{slope}_{pAuxEl}"; const PowertrainPosition pos = PowertrainPosition.BatteryElectricE3; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 2, 22.6, largeMotor: true, pAuxEl: pAuxEl); @@ -306,7 +306,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BatteryElectric const bool largeMotor = true; - var modFilename = string.Format("SimpleBatteryElectric-B3_acc_{0}-{1}_{2}", vmax, initialSoC, slope); + var modFilename = $"SimpleBatteryElectric-B3_acc_{vmax}-{initialSoC}_{slope}"; const PowertrainPosition pos = PowertrainPosition.BatteryElectricE3; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 2, 22.6, largeMotor: true); @@ -342,7 +342,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BatteryElectric const bool largeMotor = true; - var modFilename = string.Format("SimpleParallelHybrid-B3_cycle_{0}-{1}_{2}_{3}", declarationMission, initialSoC, payload, pAuxEl); + var modFilename = $"SimpleParallelHybrid-B3_cycle_{declarationMission}-{initialSoC}_{payload}_{pAuxEl}"; const PowertrainPosition pos = PowertrainPosition.BatteryElectricE3; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 2, 22.6, largeMotor: true); @@ -427,7 +427,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BatteryElectric const bool largeMotor = true; - var modFilename = string.Format("SimpleBatteryElectric-B2_constant_{0}-{1}_{2}_{3}", vmax, initialSoC, slope, pAuxEl); + var modFilename = $"SimpleBatteryElectric-B2_constant_{vmax}-{initialSoC}_{slope}_{pAuxEl}"; const PowertrainPosition pos = PowertrainPosition.BatteryElectricE2; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 2, 2, largeMotor: true, pAuxEl: pAuxEl); @@ -465,7 +465,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BatteryElectric const bool largeMotor = true; - var modFilename = string.Format("SimpleBatteryElectric-B2_stop_{0}-{1}_{2}", vmax, initialSoC, slope); + var modFilename = $"SimpleBatteryElectric-B2_stop_{vmax}-{initialSoC}_{slope}"; const PowertrainPosition pos = PowertrainPosition.BatteryElectricE2; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 2, 2, largeMotor: true); @@ -495,7 +495,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BatteryElectric const bool largeMotor = true; - var modFilename = string.Format("SimpleBatteryElectric-B2_acc_{0}-{1}_{2}", vmax, initialSoC, slope); + var modFilename = $"SimpleBatteryElectric-B2_acc_{vmax}-{initialSoC}_{slope}"; const PowertrainPosition pos = PowertrainPosition.BatteryElectricE2; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 2, 2, largeMotor: true); @@ -531,7 +531,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BatteryElectric const bool largeMotor = true; - var modFilename = string.Format("SimpleBatteryElectric-B2_cycle_{0}-{1}_{2}_{3}", declarationMission, initialSoC, payload, pAuxEl); + var modFilename = $"SimpleBatteryElectric-B2_cycle_{declarationMission}-{initialSoC}_{payload}_{pAuxEl}"; const PowertrainPosition pos = PowertrainPosition.BatteryElectricE2; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 2, 2, largeMotor: true); @@ -781,7 +781,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BatteryElectric LossMap = TransmissionLossMapReader.ReadFromFile( ratio.IsEqual(1) ? GearboxIndirectLoss : GearboxDirectLoss, ratio, - string.Format("Gear {0}", i)), + $"Gear {i}"), Ratio = ratio, //ShiftPolygon = shiftStrategy.ComputeDeclarationShiftPolygon(GearboxType.AMT, i, null, ) })).ToDictionary(k => k.Item1 + 1, v => v.Item2), diff --git a/VectoCore/VectoCoreTest/Integration/CoachAdvancedAuxPowertrain.cs b/VectoCore/VectoCoreTest/Integration/CoachAdvancedAuxPowertrain.cs index 0f66184be9b5ab7ea40becad5855ab5efbd307fd..258ae5281d6c84cdab3c2e73a143f7bd807d4010 100644 --- a/VectoCore/VectoCoreTest/Integration/CoachAdvancedAuxPowertrain.cs +++ b/VectoCore/VectoCoreTest/Integration/CoachAdvancedAuxPowertrain.cs @@ -142,8 +142,8 @@ namespace TUGraz.VectoCore.Tests.Integration new GearData { //MaxTorque = 2300.SI<NewtonMeter>(), LossMap = ratio.IsEqual(1) - ? TransmissionLossMapReader.ReadFromFile(GearboxIndirectLoss, ratio, string.Format("Gear {0}", i)) - : TransmissionLossMapReader.ReadFromFile(GearboxDirectLoss, ratio, string.Format("Gear {0}", i)), + ? TransmissionLossMapReader.ReadFromFile(GearboxIndirectLoss, ratio, $"Gear {i}") + : TransmissionLossMapReader.ReadFromFile(GearboxDirectLoss, ratio, $"Gear {i}"), Ratio = ratio, ShiftPolygon = ShiftPolygonReader.ReadFromFile(GearboxShiftPolygonFile) })) diff --git a/VectoCore/VectoCoreTest/Integration/CoachPowerTrain.cs b/VectoCore/VectoCoreTest/Integration/CoachPowerTrain.cs index 22601613c7dfc85ba1319b623cac46da94f86cc5..aca96a92aba63b6567a3273957b420b6b8f5e1c1 100644 --- a/VectoCore/VectoCoreTest/Integration/CoachPowerTrain.cs +++ b/VectoCore/VectoCoreTest/Integration/CoachPowerTrain.cs @@ -140,8 +140,8 @@ namespace TUGraz.VectoCore.Tests.Integration new GearData { //MaxTorque = 2300.SI<NewtonMeter>(), LossMap = ratio.IsEqual(1) - ? TransmissionLossMapReader.ReadFromFile(GearboxIndirectLoss, ratio, string.Format("Gear {0}", i)) - : TransmissionLossMapReader.ReadFromFile(GearboxDirectLoss, ratio, string.Format("Gear {0}", i)), + ? TransmissionLossMapReader.ReadFromFile(GearboxIndirectLoss, ratio, $"Gear {i}") + : TransmissionLossMapReader.ReadFromFile(GearboxDirectLoss, ratio, $"Gear {i}"), Ratio = ratio, ShiftPolygon = ShiftPolygonReader.ReadFromFile(GearboxShiftPolygonFile) })) diff --git a/VectoCore/VectoCoreTest/Integration/Declaration/NaturalGasVehicles.cs b/VectoCore/VectoCoreTest/Integration/Declaration/NaturalGasVehicles.cs index e6141c21ab3f9f47a74b059ec309888981fc6e06..83f6dc0b74b0c029d96daadd99b499c06260b1d7 100644 --- a/VectoCore/VectoCoreTest/Integration/Declaration/NaturalGasVehicles.cs +++ b/VectoCore/VectoCoreTest/Integration/Declaration/NaturalGasVehicles.cs @@ -118,9 +118,9 @@ namespace TUGraz.VectoCore.Tests.Integration.Declaration } var fcNode = manufacturerReport.XPathSelectElement( - string.Format("//*[local-name()='Results']/*[local-name()='Result'][{0}]//*[local-name()='FuelConsumption' and @unit='g/km']", runIdx)); + $"//*[local-name()='Results']/*[local-name()='Result'][{runIdx}]//*[local-name()='FuelConsumption' and @unit='g/km']"); var co2Node = manufacturerReport.XPathSelectElement( - string.Format("//*[local-name()='Results']/*[local-name()='Result'][{0}]//*[local-name()='CO2' and @unit='g/km']", runIdx)); + $"//*[local-name()='Results']/*[local-name()='Result'][{runIdx}]//*[local-name()='CO2' and @unit='g/km']"); Console.WriteLine("fc: {0} co2: {1}", fcNode.Value, co2Node.Value); diff --git a/VectoCore/VectoCoreTest/Integration/FullCycleDeclarationTest.cs b/VectoCore/VectoCoreTest/Integration/FullCycleDeclarationTest.cs index 09f1dcd09f0cc1f781c9a7a033f8304eec0122af..97819e4f7dad7767c2ba38d594600ff4c7d3e00d 100644 --- a/VectoCore/VectoCoreTest/Integration/FullCycleDeclarationTest.cs +++ b/VectoCore/VectoCoreTest/Integration/FullCycleDeclarationTest.cs @@ -231,14 +231,14 @@ namespace TUGraz.VectoCore.Tests.Integration var i = 5; jobContainer.Runs[i].Run.Run(); Assert.IsTrue(jobContainer.Runs[i].Run.FinishedWithoutErrors, - string.Format("{0}", jobContainer.Runs[i].ExecException)); + $"{jobContainer.Runs[i].ExecException}"); jobContainer = new JobContainer(sumData); jobContainer.AddRuns(factory1Hz); jobContainer.Runs[i].Run.Run(); Assert.IsTrue(jobContainer.Runs[i].Run.FinishedWithoutErrors, - string.Format("{0}", jobContainer.Runs[i].ExecException)); + $"{jobContainer.Runs[i].ExecException}"); var modFile = VectoCSVFile.Read(modFileName); var modFile1Hz = VectoCSVFile.Read(modFileName1Hz); @@ -248,8 +248,7 @@ namespace TUGraz.VectoCore.Tests.Integration var lineCount1Hz = modFile1Hz.Rows.Count; AssertHelper.AreRelativeEqual(lineCount1Hz, maxSeconds, - string.Format("LineCount must equal max seconds. Lines={0}, MaxSeconds={1}", lineCount1Hz, - maxSeconds), 1); + $"LineCount must equal max seconds. Lines={lineCount1Hz}, MaxSeconds={maxSeconds}", 1); // test max distance var maxDistance = modFile.Rows.Cast<DataRow>().Last().ParseDouble(ModalResultField.dist.GetShortCaption()); diff --git a/VectoCore/VectoCoreTest/Integration/Hybrid/ParallelHybridTest.cs b/VectoCore/VectoCoreTest/Integration/Hybrid/ParallelHybridTest.cs index 735123cefe2081309072b6effb2022ca9f725365..ccfa911ea3b7f0aa2df0af12c2451ce987210228 100644 --- a/VectoCore/VectoCoreTest/Integration/Hybrid/ParallelHybridTest.cs +++ b/VectoCore/VectoCoreTest/Integration/Hybrid/ParallelHybridTest.cs @@ -132,7 +132,7 @@ namespace TUGraz.VectoCore.Tests.Integration.Hybrid const bool largeMotor = true; - var modFilename = string.Format("SimpleParallelHybrid-P1_constant_{0}-{1}_{2}_{3}.vmod", vmax, initialSoC, slope, gbxType.ToXMLFormat()); + var modFilename = $"SimpleParallelHybrid-P1_constant_{vmax}-{initialSoC}_{slope}_{gbxType.ToXMLFormat()}.vmod"; const PowertrainPosition pos = PowertrainPosition.HybridP1; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 1.0, largeMotor: false, gearboxType: gbxType); @@ -178,7 +178,7 @@ namespace TUGraz.VectoCore.Tests.Integration.Hybrid const bool largeMotor = true; - var modFilename = string.Format("SimpleParallelHybrid-P1_acc_{0}-{1}_{2}_{3}.vmod", vmax, initialSoC, slope, gbxType.ToXMLFormat()); + var modFilename = $"SimpleParallelHybrid-P1_acc_{vmax}-{initialSoC}_{slope}_{gbxType.ToXMLFormat()}.vmod"; const PowertrainPosition pos = PowertrainPosition.HybridP1; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 1.0, largeMotor: false, gearboxType: gbxType); @@ -216,7 +216,7 @@ namespace TUGraz.VectoCore.Tests.Integration.Hybrid const bool largeMotor = true; - var modFilename = string.Format("SimpleParallelHybrid-P1_stop_{0}-{1}_{2}_{3}.vmod", vmax, initialSoC, slope, gbxType.ToXMLFormat()); + var modFilename = $"SimpleParallelHybrid-P1_stop_{vmax}-{initialSoC}_{slope}_{gbxType.ToXMLFormat()}.vmod"; const PowertrainPosition pos = PowertrainPosition.HybridP1; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 1.0, largeMotor: false, gearboxType: gbxType); @@ -336,7 +336,7 @@ namespace TUGraz.VectoCore.Tests.Integration.Hybrid const bool largeMotor = true; - var modFilename = string.Format("SimpleParallelHybrid-P2_acc_{0}-{1}_{2}.vmod", vmax, initialSoC, slope); + var modFilename = $"SimpleParallelHybrid-P2_acc_{vmax}-{initialSoC}_{slope}.vmod"; const PowertrainPosition pos = PowertrainPosition.HybridP2; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 1.0, largeMotor: true); @@ -371,7 +371,7 @@ namespace TUGraz.VectoCore.Tests.Integration.Hybrid const bool largeMotor = true; - var modFilename = string.Format("SimpleParallelHybrid-P2_acc_{0}-{1}_{2}_maxPwr-{3}.vmod", vmax, initialSoC, slope, maxPwrkW); + var modFilename = $"SimpleParallelHybrid-P2_acc_{vmax}-{initialSoC}_{slope}_maxPwr-{maxPwrkW}.vmod"; const PowertrainPosition pos = PowertrainPosition.HybridP2; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 1.0, largeMotor: true, maxDriveTrainPower: (maxPwrkW * 1000).SI<Watt>()); @@ -420,7 +420,7 @@ namespace TUGraz.VectoCore.Tests.Integration.Hybrid const bool largeMotor = true; - var modFilename = string.Format("SimpleParallelHybrid-P2_constant_{0}-{1}_{2}_{3}.vmod", vmax, initialSoC, slope, pAuxEl); + var modFilename = $"SimpleParallelHybrid-P2_constant_{vmax}-{initialSoC}_{slope}_{pAuxEl}.vmod"; const PowertrainPosition pos = PowertrainPosition.HybridP2; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 1.0, largeMotor: true, pAuxEl: pAuxEl); @@ -519,7 +519,7 @@ namespace TUGraz.VectoCore.Tests.Integration.Hybrid const bool largeMotor = true; - var modFilename = string.Format("SimpleParallelHybrid-P2_cycle_{0}-{1}_{2}_{3}.vmod", declarationMission, initialSoC, payload, pAuxEl); + var modFilename = $"SimpleParallelHybrid-P2_cycle_{declarationMission}-{initialSoC}_{payload}_{pAuxEl}.vmod"; const PowertrainPosition pos = PowertrainPosition.HybridP2; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 1.0, largeMotor: true, pAuxEl: pAuxEl, payload: payload.SI<Kilogram>()); @@ -864,7 +864,7 @@ namespace TUGraz.VectoCore.Tests.Integration.Hybrid //const PowertrainPosition pos = PowertrainPosition.HybridP2; var run = CreateConventionalEngineeringRun( - cycle, string.Format("ConventionalVehicle_acc_{0}_{1}.vmod", vmax, slope)); + cycle, $"ConventionalVehicle_acc_{vmax}_{slope}.vmod"); //var hybridController = (HybridController)((VehicleContainer)run.GetContainer()).HybridController; //Assert.NotNull(hybridController); @@ -893,7 +893,7 @@ namespace TUGraz.VectoCore.Tests.Integration.Hybrid const bool largeMotor = true; - var modFilename = string.Format("SimpleParallelHybrid-P2_stop_{0}-{1}_{2}.vmod", vmax, initialSoC, slope); + var modFilename = $"SimpleParallelHybrid-P2_stop_{vmax}-{initialSoC}_{slope}.vmod"; const PowertrainPosition pos = PowertrainPosition.HybridP2; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 1.0, largeMotor: true); @@ -946,7 +946,7 @@ namespace TUGraz.VectoCore.Tests.Integration.Hybrid const bool largeMotor = true; - var modFilename = string.Format("SimpleParallelHybrid-P3_constant_{0}-{1}_{2}_{3}.vmod", vmax, initialSoC, slope, pAuxEl); + var modFilename = $"SimpleParallelHybrid-P3_constant_{vmax}-{initialSoC}_{slope}_{pAuxEl}.vmod"; const PowertrainPosition pos = PowertrainPosition.HybridP3; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 1.0, largeMotor: true, pAuxEl: pAuxEl); @@ -984,7 +984,7 @@ namespace TUGraz.VectoCore.Tests.Integration.Hybrid const bool largeMotor = true; - var modFilename = string.Format("SimpleParallelHybrid-P3_acc_{0}-{1}_{2}.vmod", vmax, initialSoC, slope); + var modFilename = $"SimpleParallelHybrid-P3_acc_{vmax}-{initialSoC}_{slope}.vmod"; const PowertrainPosition pos = PowertrainPosition.HybridP3; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 1.0, largeMotor: true); @@ -1018,7 +1018,7 @@ namespace TUGraz.VectoCore.Tests.Integration.Hybrid const bool largeMotor = true; - var modFilename = string.Format("SimpleParallelHybrid-P3_stop_{0}-{1}_{2}.vmod", vmax, initialSoC, slope); + var modFilename = $"SimpleParallelHybrid-P3_stop_{vmax}-{initialSoC}_{slope}.vmod"; const PowertrainPosition pos = PowertrainPosition.HybridP3; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 1.0, largeMotor: true); @@ -1061,7 +1061,7 @@ namespace TUGraz.VectoCore.Tests.Integration.Hybrid const bool largeMotor = true; - var modFilename = string.Format("SimpleParallelHybrid-P3_cycle_{0}-{1}_{2}_{3}.vmod", declarationMission, initialSoC, payload, pAuxEl); + var modFilename = $"SimpleParallelHybrid-P3_cycle_{declarationMission}-{initialSoC}_{payload}_{pAuxEl}.vmod"; const PowertrainPosition pos = PowertrainPosition.HybridP3; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 1.0, largeMotor: true, pAuxEl: pAuxEl, payload: payload.SI<Kilogram>()); @@ -1193,7 +1193,7 @@ namespace TUGraz.VectoCore.Tests.Integration.Hybrid const bool largeMotor = true; - var modFilename = string.Format("SimpleParallelHybrid-P4_constant_{0}-{1}_{2}_{3}.vmod", vmax, initialSoC, slope, pAuxEl); + var modFilename = $"SimpleParallelHybrid-P4_constant_{vmax}-{initialSoC}_{slope}_{pAuxEl}.vmod"; const PowertrainPosition pos = PowertrainPosition.HybridP4; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 1.0, largeMotor: true, pAuxEl: pAuxEl); @@ -1232,7 +1232,7 @@ namespace TUGraz.VectoCore.Tests.Integration.Hybrid const bool largeMotor = true; - var modFilename = string.Format("SimpleParallelHybrid-P4_acc_{0}-{1}_{2}.vmod", vmax, initialSoC, slope); + var modFilename = $"SimpleParallelHybrid-P4_acc_{vmax}-{initialSoC}_{slope}.vmod"; const PowertrainPosition pos = PowertrainPosition.HybridP4; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 1.0, largeMotor: true); @@ -1265,7 +1265,7 @@ namespace TUGraz.VectoCore.Tests.Integration.Hybrid const bool largeMotor = true; - var modFilename = string.Format("SimpleParallelHybrid-P4_stop_{0}-{1}_{2}.vmod", vmax, initialSoC, slope); + var modFilename = $"SimpleParallelHybrid-P4_stop_{vmax}-{initialSoC}_{slope}.vmod"; const PowertrainPosition pos = PowertrainPosition.HybridP4; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 1.0, largeMotor: true); @@ -1307,7 +1307,7 @@ namespace TUGraz.VectoCore.Tests.Integration.Hybrid const bool largeMotor = true; - var modFilename = string.Format("SimpleParallelHybrid-P4_cycle_{0}-{1}_{2}_{3}.vmod", declarationMission, initialSoC, payload, pAuxEl); + var modFilename = $"SimpleParallelHybrid-P4_cycle_{declarationMission}-{initialSoC}_{payload}_{pAuxEl}.vmod"; const PowertrainPosition pos = PowertrainPosition.HybridP4; var job = CreateEngineeringRun( cycle, modFilename, initialSoC, pos, 1.0, largeMotor: true, pAuxEl: pAuxEl, payload: payload.SI<Kilogram>()); @@ -1717,7 +1717,7 @@ namespace TUGraz.VectoCore.Tests.Integration.Hybrid LossMap = TransmissionLossMapReader.ReadFromFile( ratio.IsEqual(1) ? GearboxIndirectLoss : GearboxDirectLoss, ratio, - string.Format("Gear {0}", i)), + $"Gear {i}"), Ratio = ratio, //ShiftPolygon = DeclarationData.Gearbox.ComputeEfficiencyShiftPolygon(i,) })).ToDictionary(k => k.Item1 + 1, v => v.Item2), @@ -1743,12 +1743,12 @@ namespace TUGraz.VectoCore.Tests.Integration.Hybrid LossMap = TransmissionLossMapReader.ReadFromFile( ratio.IsEqual(1) ? GearboxIndirectLoss : GearboxDirectLoss, ratio, - string.Format("Gear {0}", i)), + $"Gear {i}"), Ratio = ratio, //ShiftPolygon = ShiftPolygonReader.ReadFromFile(GearboxShiftPolygonFile), TorqueConverterRatio = i == 0 ? ratio : double.NaN, TorqueConverterGearLossMap = i == 0 - ? TransmissionLossMapReader.Create( 0.98, ratio, string.Format("Gear {0}", i)) + ? TransmissionLossMapReader.Create( 0.98, ratio, $"Gear {i}") : null, //TorqueConverterShiftPolygon = i == 0 ? ShiftPolygonReader.ReadFromFile(GearboxShiftPolygonFile) : null })).ToDictionary(k => k.Item1 + 1, v => v.Item2), @@ -1773,12 +1773,12 @@ namespace TUGraz.VectoCore.Tests.Integration.Hybrid LossMap = TransmissionLossMapReader.ReadFromFile( ratio.IsEqual(1) ? GearboxIndirectLoss : GearboxDirectLoss, ratio, - string.Format("Gear {0}", i)), + $"Gear {i}"), Ratio = ratio, //ShiftPolygon = ShiftPolygonReader.ReadFromFile(GearboxShiftPolygonFile), TorqueConverterRatio = i == 0 ? 1.0 : double.NaN, TorqueConverterGearLossMap = i == 0 - ? TransmissionLossMapReader.Create(1.0, ratio, string.Format("Gear {0}", i)) + ? TransmissionLossMapReader.Create(1.0, ratio, $"Gear {i}") : null, //TorqueConverterShiftPolygon = i == 0 ? ShiftPolygonReader.ReadFromFile(GearboxShiftPolygonFile) : null })).ToDictionary(k => k.Item1 + 1, v => v.Item2), diff --git a/VectoCore/VectoCoreTest/Integration/Truck40tPowerTrain.cs b/VectoCore/VectoCoreTest/Integration/Truck40tPowerTrain.cs index 4920c206a530c4dc0e411e133160a4ffff87531d..1a36bd0abcafd967fd32d1547fea96b7e2e42781 100644 --- a/VectoCore/VectoCoreTest/Integration/Truck40tPowerTrain.cs +++ b/VectoCore/VectoCoreTest/Integration/Truck40tPowerTrain.cs @@ -157,7 +157,7 @@ namespace TUGraz.VectoCore.Tests.Integration //MaxTorque = 2300.SI<NewtonMeter>(), LossMap = TransmissionLossMapReader.ReadFromFile(ratio.IsEqual(1) ? GearboxIndirectLoss : GearboxDirectLoss, ratio, - string.Format("Gear {0}", i)), + $"Gear {i}"), Ratio = ratio, ShiftPolygon = ShiftPolygonReader.ReadFromFile(ShiftPolygonFile) })).ToDictionary(k => k.Item1 + 1, v => v.Item2), diff --git a/VectoCore/VectoCoreTest/Models/Declaration/ShiftPolygonTest.cs b/VectoCore/VectoCoreTest/Models/Declaration/ShiftPolygonTest.cs index c6d4382d705f21cdd8d3618c384f762275637ab6..45bad7552f1271ba7fbf06ad9db49781b3b0e331 100644 --- a/VectoCore/VectoCoreTest/Models/Declaration/ShiftPolygonTest.cs +++ b/VectoCore/VectoCoreTest/Models/Declaration/ShiftPolygonTest.cs @@ -595,11 +595,11 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration shiftLines += "Gear " + gear + "\n"; shiftLines += "Upshift\n"; foreach (var shiftPolygonEntry in shiftPolygon.Upshift) { - shiftLines += string.Format("{0} {1}\n", shiftPolygonEntry.AngularSpeed.AsRPM, shiftPolygonEntry.Torque.Value()); + shiftLines += $"{shiftPolygonEntry.AngularSpeed.AsRPM} {shiftPolygonEntry.Torque.Value()}\n"; } shiftLines += "Downshift\n"; foreach (var shiftPolygonEntry in shiftPolygon.Downshift) { - shiftLines += string.Format("{0} {1}\n", shiftPolygonEntry.AngularSpeed.AsRPM, shiftPolygonEntry.Torque.Value()); + shiftLines += $"{shiftPolygonEntry.AngularSpeed.AsRPM} {shiftPolygonEntry.Torque.Value()}\n"; } } } @@ -654,11 +654,11 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration shiftLines += "Gear " + gear + "\n"; shiftLines += "Upshift\n"; foreach (var shiftPolygonEntry in shiftPolygon.Upshift) { - shiftLines += string.Format("{0} {1}\n", shiftPolygonEntry.AngularSpeed.AsRPM, shiftPolygonEntry.Torque.Value()); + shiftLines += $"{shiftPolygonEntry.AngularSpeed.AsRPM} {shiftPolygonEntry.Torque.Value()}\n"; } shiftLines += "Downshift\n"; foreach (var shiftPolygonEntry in shiftPolygon.Downshift) { - shiftLines += string.Format("{0} {1}\n", shiftPolygonEntry.AngularSpeed.AsRPM, shiftPolygonEntry.Torque.Value()); + shiftLines += $"{shiftPolygonEntry.AngularSpeed.AsRPM} {shiftPolygonEntry.Torque.Value()}\n"; } } } @@ -756,11 +756,11 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration str += "Gear " + g + "\n"; str += "downshift\n"; foreach (var entry in shiftPolygon.Downshift) { - str += string.Format("{0} {1}\n", entry.AngularSpeed.AsRPM, entry.Torque.Value()); + str += $"{entry.AngularSpeed.AsRPM} {entry.Torque.Value()}\n"; } str += "upshift\n"; foreach (var entry in shiftPolygon.Upshift) { - str += string.Format("{0} {1}\n", entry.AngularSpeed.AsRPM, entry.Torque.Value()); + str += $"{entry.AngularSpeed.AsRPM} {entry.Torque.Value()}\n"; } g++; } @@ -911,11 +911,11 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration str += "Gear " + g + "\n"; str += "downshift\n"; foreach (var entry in shiftPolygon.Downshift) { - str += string.Format("{0} {1}\n", entry.AngularSpeed.AsRPM, entry.Torque.Value()); + str += $"{entry.AngularSpeed.AsRPM} {entry.Torque.Value()}\n"; } str += "upshift\n"; foreach (var entry in shiftPolygon.Upshift) { - str += string.Format("{0} {1}\n", entry.AngularSpeed.AsRPM, entry.Torque.Value()); + str += $"{entry.AngularSpeed.AsRPM} {entry.Torque.Value()}\n"; } g++; } diff --git a/VectoCore/VectoCoreTest/Models/Simulation/LACDecisionFactorTest.cs b/VectoCore/VectoCoreTest/Models/Simulation/LACDecisionFactorTest.cs index 2b0f28f3e37522ebccae43a4cb6724255251ed5a..e7fdd14ffb450f66950c05f118c7a3e9e13e2683 100644 --- a/VectoCore/VectoCoreTest/Models/Simulation/LACDecisionFactorTest.cs +++ b/VectoCore/VectoCoreTest/Models/Simulation/LACDecisionFactorTest.cs @@ -49,15 +49,15 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation for (var vTarget = vVehicle; vTarget > 0; vTarget -= 1.KMPHtoMeterPerSecond()) { var df_coast = new LACDecisionFactor().Lookup(vTarget, vVehicle - vTarget); if (vTarget < 48.KMPHtoMeterPerSecond()) { - AssertHelper.AreRelativeEqual(df_coast, 2.5, string.Format("vVehicle: {0}, vTarget: {1}", vVehicle, vTarget)); + AssertHelper.AreRelativeEqual(df_coast, 2.5, $"vVehicle: {vVehicle}, vTarget: {vTarget}"); } if (vVehicle - vTarget > 11) { - AssertHelper.AreRelativeEqual(df_coast, 2.5, string.Format("vVehicle: {0}, vTarget: {1}", vVehicle, vTarget)); + AssertHelper.AreRelativeEqual(df_coast, 2.5, $"vVehicle: {vVehicle}, vTarget: {vTarget}"); } if (vTarget > 52.KMPHtoMeterPerSecond() && vVehicle - vTarget < 9.KMPHtoMeterPerSecond()) { - AssertHelper.AreRelativeEqual(df_coast, 1.0, string.Format("vVehicle: {0}, vTarget: {1}", vVehicle, vTarget)); + AssertHelper.AreRelativeEqual(df_coast, 1.0, $"vVehicle: {vVehicle}, vTarget: {vTarget}"); } } } diff --git a/VectoCore/VectoCoreTest/Models/Simulation/LossMapRangeValidationTest.cs b/VectoCore/VectoCoreTest/Models/Simulation/LossMapRangeValidationTest.cs index 54c2a9ee725e251b89941ba056795151d55f7f1b..fd782aaed4c0e9a95d953ad23803bd23b8e7caeb 100644 --- a/VectoCore/VectoCoreTest/Models/Simulation/LossMapRangeValidationTest.cs +++ b/VectoCore/VectoCoreTest/Models/Simulation/LossMapRangeValidationTest.cs @@ -203,7 +203,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation new GearData { // MaxTorque = 2300.SI<NewtonMeter>(), LossMap = TransmissionLossMapReader.ReadFromFile(!ratio.IsEqual(1.0) ? directlossMap : indirectLossMap, ratio, - string.Format("Gear {0}", i)), + $"Gear {i}"), Ratio = ratio, ShiftPolygon = ShiftPolygonReader.ReadFromFile(ShiftPolygonFile) })) @@ -284,7 +284,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation jobContainer.WaitFinished(); foreach (var r in jobContainer.Runs) { - Assert.IsTrue(r.Run.FinishedWithoutErrors, string.Format("{0}", r.ExecException)); + Assert.IsTrue(r.Run.FinishedWithoutErrors, $"{r.ExecException}"); } } diff --git a/VectoCore/VectoCoreTest/Models/Simulation/SimulationTests.cs b/VectoCore/VectoCoreTest/Models/Simulation/SimulationTests.cs index 260e0744e603c91a55fd1abbb8747f565399e1d7..32122b7005c4b72c6b040a2bb985a22b5c2b7a9e 100644 --- a/VectoCore/VectoCoreTest/Models/Simulation/SimulationTests.cs +++ b/VectoCore/VectoCoreTest/Models/Simulation/SimulationTests.cs @@ -96,7 +96,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation jobContainer.WaitFinished(); foreach (var r in jobContainer.Runs) { - Assert.IsTrue(r.Run.FinishedWithoutErrors, string.Format("{0}", r.ExecException)); + Assert.IsTrue(r.Run.FinishedWithoutErrors, $"{r.ExecException}"); } ResultFileHelper.TestModFile(expected, actual); @@ -132,7 +132,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation jobContainer.WaitFinished(); foreach (var run in jobContainer.Runs) { - Assert.IsTrue(run.Run.FinishedWithoutErrors, string.Format("{0}", run.ExecException)); + Assert.IsTrue(run.Run.FinishedWithoutErrors, $"{run.ExecException}"); } ResultFileHelper.TestSumFile(@"TestData\Results\EngineOnlyCycles\24t Coach EngineOnly.vsum", diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/ATGearboxTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/ATGearboxTest.cs index 0cee2a4fc8e67c0c439964b4992b710df0cd856b..27530fdf0d401cfd5a73408619598a39329168f0 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponent/ATGearboxTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/ATGearboxTest.cs @@ -125,7 +125,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent var cycle = SimpleDrivingCycles.CreateCycleData(cycleData); var run = ATPowerTrain.CreateEngineeringRun( cycle, gbxType, - string.Format("AT_Vehicle_Drive-TC-{0}.vmod", gbxType == GearboxType.ATSerial ? "ser" : "ps")); + $"AT_Vehicle_Drive-TC-{(gbxType == GearboxType.ATSerial ? "ser" : "ps")}.vmod"); run.Run(); Assert.IsTrue(run.FinishedWithoutErrors); @@ -141,7 +141,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent var cycle = SimpleDrivingCycles.CreateCycleData(cycleData); var run = ATPowerTrain.CreateEngineeringRun( cycle, gbxType, - string.Format("AT_Vehicle_Drive-TC_shiftup-{0}.vmod", gbxType == GearboxType.ATSerial ? "ser" : "ps")); + $"AT_Vehicle_Drive-TC_shiftup-{(gbxType == GearboxType.ATSerial ? "ser" : "ps")}.vmod"); run.Run(); Assert.IsTrue(run.FinishedWithoutErrors); @@ -157,7 +157,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent var cycle = SimpleDrivingCycles.CreateCycleData(cycleData); var run = ATPowerTrain.CreateEngineeringRun( cycle, gbxType, - string.Format("AT_Vehicle_Drive-TC_shiftdown-{0}.vmod", gbxType == GearboxType.ATSerial ? "ser" : "ps")); + $"AT_Vehicle_Drive-TC_shiftdown-{(gbxType == GearboxType.ATSerial ? "ser" : "ps")}.vmod"); run.Run(); Assert.IsTrue(run.FinishedWithoutErrors); @@ -181,14 +181,12 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent var cycle = SimpleDrivingCycles.ReadDeclarationCycle(cycleName); var run = ATPowerTrain.CreateEngineeringRun( cycle, gbxType, - string.Format("AT_Vehicle_Drive-TC_{0}-{1}.vmod", cycleName, gbxType == GearboxType.ATSerial ? "ser" : "ps")); + $"AT_Vehicle_Drive-TC_{cycleName}-{(gbxType == GearboxType.ATSerial ? "ser" : "ps")}.vmod"); var sumWriter = new SummaryDataContainer( new FileOutputWriter( - string.Format( - "AT_Vehicle_Drive-TC_{0}-{1}", cycleName, - gbxType == GearboxType.ATSerial ? "ser" : "ps"))); + $"AT_Vehicle_Drive-TC_{cycleName}-{(gbxType == GearboxType.ATSerial ? "ser" : "ps")}")); ((VehicleContainer)run.GetContainer()).WriteSumData = (modData) => sumWriter.Write(run.GetContainer().ModalData, 0, 0, run.GetContainer().RunData); run.Run(); diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/CombustionEngineTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/CombustionEngineTest.cs index a5c6c0c3da5393aa6efeed20604ba53025aefeb9..936f118c7886ce0de584304e000cd64f18af3a21 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponent/CombustionEngineTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/CombustionEngineTest.cs @@ -213,7 +213,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent engine.CommitSimulationStep(t, dt, modalData); Assert.AreEqual(expectedResults.Rows[i].ParseDouble(0), t.Value(), 0.001, "Time"); Assert.AreEqual(expectedResults.Rows[i].ParseDouble(1), ((SI)modalData[ModalResultField.P_ice_full]).Value(), 0.1, - string.Format("Load in timestep {0}", t)); + $"Load in timestep {t}"); modalData.CommitSimulationStep(); } modalData.Finish(VectoRun.Status.Success); @@ -270,7 +270,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent engine.CommitSimulationStep(t, dt, modalData); Assert.AreEqual(expectedResults.Rows[i].ParseDouble(0), t.Value(), 0.001, "Time"); Assert.AreEqual(expectedResults.Rows[i].ParseDouble(1), ((SI)modalData[ModalResultField.P_ice_full]).Value(), 0.1, - string.Format("Load in timestep {0}", t)); + $"Load in timestep {t}"); modalData.CommitSimulationStep(); } modalData.Finish(VectoRun.Status.Success); @@ -440,8 +440,8 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent container.CommitSimulationStep(absTime, dt); engSpeedResults.Add(new { absTime, engine.PreviousState.EngineSpeed, engine.PreviousState.EnginePower }); - Assert.AreEqual(engineSpeed[i], engine.PreviousState.EngineSpeed.AsRPM, Tolerance, string.Format("entry {0}", i)); - Assert.AreEqual(enginePower[i], engine.PreviousState.EnginePower.Value(), Tolerance, string.Format("entry {0}", i)); + Assert.AreEqual(engineSpeed[i], engine.PreviousState.EngineSpeed.AsRPM, Tolerance, $"entry {i}"); + Assert.AreEqual(enginePower[i], engine.PreviousState.EnginePower.Value(), Tolerance, $"entry {i}"); absTime += dt; } //dataWriter.Finish(); diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxTest.cs index df4c5cff9fe53af99fd093a2b712e6aa8a715fc7..78f092674ae9e186a6a90721d1a479bc17915054 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxTest.cs @@ -98,7 +98,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent new GearData { // MaxTorque = 2300.SI<NewtonMeter>(), LossMap = TransmissionLossMapReader.ReadFromFile(i != 6 ? IndirectLossMap : DirectLossMap, ratio, - string.Format("Gear {0}", i)), + $"Gear {i}"), Ratio = ratio, ShiftPolygon = ShiftPolygonReader.ReadFromFile(GearboxShiftPolygonFile) })) diff --git a/VectoCore/VectoCoreTest/Reports/ModDataTest.cs b/VectoCore/VectoCoreTest/Reports/ModDataTest.cs index d981033fc4ca1a7de4b41430a244ba7bbeec52b0..c6680bc1cba6c5891213cbc1686de7832105357d 100644 --- a/VectoCore/VectoCoreTest/Reports/ModDataTest.cs +++ b/VectoCore/VectoCoreTest/Reports/ModDataTest.cs @@ -267,7 +267,7 @@ namespace TUGraz.VectoCore.Tests.Reports continue; } var numParts = parts[i].Split('.'); - Assert.AreEqual(2, numParts.Length, string.Format("Line {0}: column {1}: value {2}", lineCnt, i, parts[i])); + Assert.AreEqual(2, numParts.Length, $"Line {lineCnt}: column {i}: value {parts[i]}"); Assert.IsTrue(numParts[0].Length > 0); Assert.AreEqual(4, numParts[1].Length); } diff --git a/VectoCore/VectoCoreTest/Utils/AssertHelper.cs b/VectoCore/VectoCoreTest/Utils/AssertHelper.cs index f07d2933f2250c215071ba03dbd3e91804245554..0d5ffdf3bf5974dbaabfca9de3962795c6dcdcdd 100644 --- a/VectoCore/VectoCoreTest/Utils/AssertHelper.cs +++ b/VectoCore/VectoCoreTest/Utils/AssertHelper.cs @@ -69,7 +69,7 @@ namespace TUGraz.VectoCore.Tests.Utils double toleranceFactor = DoubleExtensionMethods.ToleranceFactor, string message = null) { Assert.IsTrue(actual.HasEqualUnit(expected), - string.Format("Wrong SI Units: expected: {0}, actual: {1}", expected.ToBasicUnits(), actual.ToBasicUnits())); + $"Wrong SI Units: expected: {expected.ToBasicUnits()}, actual: {actual.ToBasicUnits()}"); AreRelativeEqual(expected.Value(), actual.Value(), toleranceFactor: toleranceFactor, message: message); } @@ -105,7 +105,7 @@ namespace TUGraz.VectoCore.Tests.Utils if (double.IsNaN(expected.Value)) { Assert.IsTrue(double.IsNaN(actual.Value), - string.Format("Actual value is not NaN. Expected: {0}, Actual: {1}{2}", expected, actual, message)); + $"Actual value is not NaN. Expected: {expected}, Actual: {actual}{message}"); return; } diff --git a/VectoCore/VectoCoreTest/Utils/GraphWriter.cs b/VectoCore/VectoCoreTest/Utils/GraphWriter.cs index 2df475d9d13d9e1b84fa59fcb1a5578362f96f29..3951ad1661c967b405c7d2f924862a781d2b920d 100644 --- a/VectoCore/VectoCoreTest/Utils/GraphWriter.cs +++ b/VectoCore/VectoCoreTest/Utils/GraphWriter.cs @@ -96,8 +96,7 @@ namespace TUGraz.VectoCore.Tests.Utils var titleHeight = (50 * 100.0f) / (_diagramSize.Height * Yfields.Length); foreach (var xfield in Xfields) { - var fileName = string.Format("{0}_{1}.png", Path.GetFileNameWithoutExtension(fileNameV3), - xfield.GetName()); + var fileName = $"{Path.GetFileNameWithoutExtension(fileNameV3)}_{xfield.GetName()}.png"; var x = LoadData(modDataV3, xfield.GetName()); var x2 = new[] { double.NegativeInfinity }; @@ -282,8 +281,7 @@ namespace TUGraz.VectoCore.Tests.Utils var titleHeight = (50 * 100.0f) / (_diagramSize.Height * yfields.Length); //foreach (var xfield in xfields) { - var fileName = string.Format("{0}_{1}-{2:D3}_{3:D3}.png", Path.GetFileNameWithoutExtension(fileNameV3), - xfield.GetName(), (int)(start / 1000), (int)(end / 1000)); + var fileName = $"{Path.GetFileNameWithoutExtension(fileNameV3)}_{xfield.GetName()}-{(int)(start / 1000):D3}_{(int)(end / 1000):D3}.png"; var x = LoadData(modDataV3, xfield.GetName()); var x2 = new[] { double.NegativeInfinity }; @@ -327,12 +325,12 @@ namespace TUGraz.VectoCore.Tests.Utils seriesGrad.YAxisType = AxisType.Secondary; } - var series1 = CreateSeries(string.Format("Vecto 3 - {0}", yfield), legend, chartArea, chart, + var series1 = CreateSeries($"Vecto 3 - {yfield}", legend, chartArea, chart, Color.Blue, x, y); if (fileNameV22 != null) { var y2 = LoadData(modDataV22, yfield.GetName()); - var series2 = CreateSeries(string.Format("Vecto 2.2 - {0}", yfield), legend, chartArea, chart, + var series2 = CreateSeries($"Vecto 2.2 - {yfield}", legend, chartArea, chart, Color.Red, x2, y2); } diff --git a/VectoCore/VectoCoreTest/Utils/MockModalDataContainer.cs b/VectoCore/VectoCoreTest/Utils/MockModalDataContainer.cs index 9aeb9e2e7d05cbc1ea475b47f7a8101952a3c4be..3caea6a689b1eceddcde9ead2c5f40093e4a1591 100644 --- a/VectoCore/VectoCoreTest/Utils/MockModalDataContainer.cs +++ b/VectoCore/VectoCoreTest/Utils/MockModalDataContainer.cs @@ -89,7 +89,7 @@ namespace TUGraz.VectoCore.Tests.Utils FuelColumns[entry] = new Dictionary<ModalResultField, DataColumn>(); foreach (var fcCol in ModalDataContainer.FuelConsumptionSignals) { var col = Data.Columns.Add( - fuels.Count == 1 ? fcCol.GetName() : string.Format("{0}_{1}", fcCol.GetName(), entry.FuelType.GetLabel()), + fuels.Count == 1 ? fcCol.GetName() : $"{fcCol.GetName()}_{entry.FuelType.GetLabel()}", typeof(SI)); col.ExtendedProperties[ModalResults.ExtendedPropertyNames.Decimals] = fcCol.GetAttribute().Decimals; diff --git a/VectoCore/VectoCoreTest/Utils/ResultFileHelper.cs b/VectoCore/VectoCoreTest/Utils/ResultFileHelper.cs index 35e50b24b2b151b13db4a53c16a6805093c3452c..d0d7bf5d0ec1dd78370a5e6bd1fbdf07b0b59aca 100644 --- a/VectoCore/VectoCoreTest/Utils/ResultFileHelper.cs +++ b/VectoCore/VectoCoreTest/Utils/ResultFileHelper.cs @@ -117,7 +117,7 @@ namespace TUGraz.VectoCore.Tests.Utils foreach (var field in testColumns ?? new string[0]) { Assert.AreEqual(expectedRow.ParseDoubleOrGetDefault(field), actualRow.ParseDoubleOrGetDefault(field), 1e-4, - string.Format("t: {0} field: {1}", i, field)); + $"t: {i} field: {field}"); } } } @@ -150,7 +150,7 @@ namespace TUGraz.VectoCore.Tests.Utils foreach (var field in testColumns ?? new string[0]) { AssertHelper.AreRelativeEqual(expectedRow.ParseDoubleOrGetDefault(field), actualRow.ParseDoubleOrGetDefault(field), - string.Format("t: {0} field: {1}", i, field)); + $"t: {i} field: {field}"); } } } diff --git a/VectoCore/VectoCoreTest/XML/XMLDeclarationInputTest.cs b/VectoCore/VectoCoreTest/XML/XMLDeclarationInputTest.cs index 3f59c372a9924c463624ea800e56a260a0e17ed6..f333143bc0587336835d882229873095f6e40667 100644 --- a/VectoCore/VectoCoreTest/XML/XMLDeclarationInputTest.cs +++ b/VectoCore/VectoCoreTest/XML/XMLDeclarationInputTest.cs @@ -762,7 +762,7 @@ namespace TUGraz.VectoCore.Tests.XML Assert.AreEqual(ptoGearWheel, inputDataProvider.JobInputData.Vehicle.Components.PTOTransmissionInputData.PTOTransmissionType); } else { - Assert.AreEqual(string.Format("{0} - {1}", ptoGearWheel, ptoOther), + Assert.AreEqual($"{ptoGearWheel} - {ptoOther}", inputDataProvider.JobInputData.Vehicle.Components.PTOTransmissionInputData.PTOTransmissionType); } Assert.NotNull(DeclarationData.PTOTransmission.Lookup(inputDataProvider.JobInputData.Vehicle.Components @@ -1041,16 +1041,16 @@ namespace TUGraz.VectoCore.Tests.XML public static string[] GetEnumOptions(string xmlType, string schemaVersion) { Stream resource; - var schemaFile = string.Format("VectoDeclarationDefinitions{0}.xsd", "." + schemaVersion); + var schemaFile = $"VectoDeclarationDefinitions{"." + schemaVersion}.xsd"; try { resource = RessourceHelper.LoadResourceAsStream(RessourceHelper.ResourceType.XMLSchema, schemaFile); } catch (Exception e) { - throw new Exception(string.Format("Unknown XML schema! version: {0}, xsd: {1}", schemaVersion, schemaFile), e); + throw new Exception($"Unknown XML schema! version: {schemaVersion}, xsd: {schemaFile}", e); } var reader = new XPathDocument(resource); var nav = reader.CreateNavigator(); var nodes = nav.Select( - string.Format("//*[local-name()='simpleType' and @name='{0}']//*[local-name()='enumeration']/@value", xmlType)); + $"//*[local-name()='simpleType' and @name='{xmlType}']//*[local-name()='enumeration']/@value"); var retVal = new List<string>(); foreach (var node in nodes) { retVal.Add(node.ToString()); diff --git a/VectoCore/VectoCoreTest/XML/XMLEngineeringInputSingleTest.cs b/VectoCore/VectoCoreTest/XML/XMLEngineeringInputSingleTest.cs index 0aa4f25fc2a95fc69c4ad1b1ffeff809990074b4..ef8fd5a2144e7737f6fb90bd6b74ada8955aa99d 100644 --- a/VectoCore/VectoCoreTest/XML/XMLEngineeringInputSingleTest.cs +++ b/VectoCore/VectoCoreTest/XML/XMLEngineeringInputSingleTest.cs @@ -254,7 +254,7 @@ namespace TUGraz.VectoCore.Tests.XML XMLNames.Component_AxleWheels, XMLNames.ComponentDataWrapper, XMLNames.AxleWheels_Axles) + - string.Format("/*[@{0}={1}]", XMLNames.AxleWheels_Axles_Axle_AxleNumber_Attr, "1") + $"/*[@{XMLNames.AxleWheels_Axles_Axle_AxleNumber_Attr}={"1"}]" ); firstAxle.MoveToAttribute(XMLNames.AxleWheels_Axles_Axle_AxleNumber_Attr, string.Empty); firstAxle.SetTypedValue(2); @@ -290,7 +290,7 @@ namespace TUGraz.VectoCore.Tests.XML XMLNames.Component_AxleWheels, XMLNames.ComponentDataWrapper, XMLNames.AxleWheels_Axles) + - string.Format("/*[@{0}={1}]", XMLNames.AxleWheels_Axles_Axle_AxleNumber_Attr, "1") + $"/*[@{XMLNames.AxleWheels_Axles_Axle_AxleNumber_Attr}={"1"}]" ); firstAxle.MoveToAttribute(XMLNames.AxleWheels_Axles_Axle_AxleNumber_Attr, string.Empty); firstAxle.SetTypedValue(0); @@ -323,8 +323,7 @@ namespace TUGraz.VectoCore.Tests.XML XMLNames.Vehicle_Components, XMLNames.Component_AxleWheels, XMLNames.ComponentDataWrapper, - XMLNames.AxleWheels_Axles) + - string.Format("/*[@{0}={1}]", XMLNames.AxleWheels_Axles_Axle_AxleNumber_Attr, "1") + XMLNames.AxleWheels_Axles) + $"/*[@{XMLNames.AxleWheels_Axles_Axle_AxleNumber_Attr}={"1"}]" ); firstAxle.MoveToAttribute(XMLNames.AxleWheels_Axles_Axle_AxleNumber_Attr, string.Empty); firstAxle.SetTypedValue(3);