refactor "new()"

This commit is contained in:
Tyrel Souza 2022-07-26 01:52:37 -04:00
parent e08fca912f
commit 399cc7b018
4 changed files with 18 additions and 20 deletions

View File

@ -10,16 +10,16 @@ namespace BenchtopParser {
public String? ProgramNumber { get; set; } public String? ProgramNumber { get; set; }
// Config Groups. TODO: rename to w/e the heck they are. // Config Groups. TODO: rename to w/e the heck they are.
public Dictionary<String, Configuration> A = new Dictionary<String, Configuration>(); public Dictionary<String, Configuration> A = new();
public Dictionary<String, Configuration> I = new Dictionary<String, Configuration>(); public Dictionary<String, Configuration> I = new();
public Dictionary<String, Configuration> M = new Dictionary<String, Configuration>(); public Dictionary<String, Configuration> M = new();
public Dictionary<String, Configuration> O = new Dictionary<String, Configuration>(); public Dictionary<String, Configuration> O = new();
public Dictionary<String, Configuration> P = new Dictionary<String, Configuration>(); public Dictionary<String, Configuration> P = new();
public Dictionary<String, Configuration> R = new Dictionary<String, Configuration>(); public Dictionary<String, Configuration> R = new();
public Dictionary<String, Configuration> S = new Dictionary<String, Configuration>(); public Dictionary<String, Configuration> S = new();
public Dictionary<String, Configuration> T = new Dictionary<String, Configuration>(); public Dictionary<String, Configuration> T = new();
public Dictionary<String, Configuration> U = new Dictionary<String, Configuration>(); public Dictionary<String, Configuration> U = new();
public Dictionary<String, Configuration> X = new Dictionary<String, Configuration>(); public Dictionary<String, Configuration> X = new();
public string Name() { public string Name() {
if (M != null && M["Name"] != null && M["Name"].value != null) { if (M != null && M["Name"] != null && M["Name"].value != null) {
@ -77,7 +77,7 @@ namespace BenchtopParser {
} }
public class ProgramConfig { public class ProgramConfig {
public Dictionary<String, Program> programs = new Dictionary<String, Program>(); public Dictionary<String, Program> programs = new();
public ProgramConfig(String program_config_value) { public ProgramConfig(String program_config_value) {
Program? current = null; Program? current = null;
@ -124,7 +124,7 @@ namespace BenchtopParser {
var data = programnumber_group_data[2]; var data = programnumber_group_data[2];
if (data.StartsWith("=")) { continue; /* comment line */ } if (data.StartsWith("=")) { continue; /* comment line */ }
Configuration lineConfig = new Configuration(configLine, data); Configuration lineConfig = new(configLine, data);
// Deal with this group logic // Deal with this group logic
if (current != null) { if (current != null) {

View File

@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace BenchtopParser { namespace BenchtopParser {
public class TransducerVerify { public class TransducerVerify {
public Dictionary<int, Transducer> transducers = new Dictionary<int, Transducer>(); public Dictionary<int, Transducer> transducers = new();
public int indent = 26; public int indent = 26;
@ -80,7 +80,7 @@ namespace BenchtopParser {
public class Transducer { public class Transducer {
public int id; public int id;
public String? name; public String? name;
public Dictionary<String, String> parameters = new Dictionary<String, String>(); public Dictionary<String, String> parameters = new();
public Transducer(int id) { public Transducer(int id) {
this.id = id; this.id = id;
} }

View File

@ -11,7 +11,7 @@ namespace BenchtopParserTests {
[Test] [Test]
public void Test_ProgramConfig() { public void Test_ProgramConfig() {
var programConfigs = new BenchtopParser.ProgramConfig(program_config_value); BenchtopParser.ProgramConfig programConfigs = new(program_config_value);
Assert.IsNotNull(programConfigs); Assert.IsNotNull(programConfigs);
// Check that group collecting works - // Check that group collecting works -
@ -38,11 +38,9 @@ namespace BenchtopParserTests {
[Test] [Test]
public void Test_ProgramConfig_AddToGroup() { public void Test_ProgramConfig_AddToGroup() {
// Adds the "namename" config to X group // Adds the "namename" config to X group
BenchtopParser.Configuration config = new BenchtopParser.Configuration("namename", "b", "c", "d"); BenchtopParser.Configuration config = new("namename", "b", "c", "d");
String group = "x"; //testing force upper check too. String group = "x"; //testing force upper check too.
BenchtopParser.Program program = new BenchtopParser.Program(); BenchtopParser.Program program = new();
program.ProgramNumber = "P1";
program.AddToGroup(group, config); program.AddToGroup(group, config);
var check = program.X["namename"]; var check = program.X["namename"];

View File

@ -10,7 +10,7 @@ namespace BenchtopParserTests {
[Test] [Test]
public void Test_TransducerVerify() { public void Test_TransducerVerify() {
BenchtopParser.TransducerVerify tv = new BenchtopParser.TransducerVerify(transducer_verify_value); BenchtopParser.TransducerVerify tv = new(transducer_verify_value);
Assert.That(tv.transducers[1].id, Is.EqualTo(1)); Assert.That(tv.transducers[1].id, Is.EqualTo(1));
Assert.That(tv.transducers[1].name, Is.EqualTo("CTS D34-442 115PSIA")); Assert.That(tv.transducers[1].name, Is.EqualTo("CTS D34-442 115PSIA"));
} }