solidify variable types from var
This commit is contained in:
parent
399cc7b018
commit
b187502d92
@ -31,7 +31,7 @@ namespace BenchtopParser {
|
|||||||
public void AddToGroup(String group, Configuration config) {
|
public void AddToGroup(String group, Configuration config) {
|
||||||
// UGLY - but helpful later.
|
// UGLY - but helpful later.
|
||||||
// TODO: Find out what the config names are and MAKE A MAP
|
// TODO: Find out what the config names are and MAKE A MAP
|
||||||
var name = config.name;
|
string name = config.name;
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
throw new Exception("Name is null, adding before Config has set name");
|
throw new Exception("Name is null, adding before Config has set name");
|
||||||
}
|
}
|
||||||
@ -81,7 +81,7 @@ namespace BenchtopParser {
|
|||||||
public ProgramConfig(String program_config_value) {
|
public ProgramConfig(String program_config_value) {
|
||||||
Program? current = null;
|
Program? current = null;
|
||||||
|
|
||||||
foreach (var line in program_config_value.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)) {
|
foreach (string line in program_config_value.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)) {
|
||||||
List<String> configLine = line.Split("\t").ToList();
|
List<String> configLine = line.Split("\t").ToList();
|
||||||
if (configLine.Count < 2) {
|
if (configLine.Count < 2) {
|
||||||
throw new Exception("Invalid Program Config, please provide an I28 Program Config file data");
|
throw new Exception("Invalid Program Config, please provide an I28 Program Config file data");
|
||||||
@ -107,7 +107,7 @@ namespace BenchtopParser {
|
|||||||
// TODO: What if multiple configs how to handle start and stop?
|
// TODO: What if multiple configs how to handle start and stop?
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
var config = configLine[0].Split(",", 2).ToList();
|
List<string> config = configLine[0].Split(",", 2).ToList();
|
||||||
if (configLine.Count == 1) {
|
if (configLine.Count == 1) {
|
||||||
// Set Program Number
|
// Set Program Number
|
||||||
if (current == null) {
|
if (current == null) {
|
||||||
@ -118,10 +118,10 @@ namespace BenchtopParser {
|
|||||||
}
|
}
|
||||||
/* CREATE A CONFIGURATION */
|
/* CREATE A CONFIGURATION */
|
||||||
|
|
||||||
var value = config[1];
|
string value = config[1];
|
||||||
|
|
||||||
var programnumber_group_data = value.Split('\\'); // snake case as its three values
|
string[] programnumber_group_data = value.Split('\\'); // snake case as its three values
|
||||||
var data = programnumber_group_data[2];
|
string data = programnumber_group_data[2];
|
||||||
if (data.StartsWith("=")) { continue; /* comment line */ }
|
if (data.StartsWith("=")) { continue; /* comment line */ }
|
||||||
|
|
||||||
Configuration lineConfig = new(configLine, data);
|
Configuration lineConfig = new(configLine, data);
|
||||||
|
@ -19,31 +19,31 @@ namespace BenchtopParser {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
public void SetIndent(int id, String line) {
|
public void SetIndent(int id, String line) {
|
||||||
var endOfCurrentTransducerKey = $"Transducer {id}".Length;
|
int endOfCurrentTransducerKey = $"Transducer {id}".Length;
|
||||||
var restOfLine = line.Substring(endOfCurrentTransducerKey);
|
string restOfLine = line.Substring(endOfCurrentTransducerKey);
|
||||||
var additionalSpaces = restOfLine.TakeWhile(c => c == ' ').Count();
|
int additionalSpaces = restOfLine.TakeWhile(c => c == ' ').Count();
|
||||||
// length 1 based, remove 1, then add additional spaces
|
// length 1 based, remove 1, then add additional spaces
|
||||||
this.indent = endOfCurrentTransducerKey - 1 + additionalSpaces;
|
this.indent = endOfCurrentTransducerKey - 1 + additionalSpaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TransducerVerify(String transducer_verify_value) {
|
public TransducerVerify(String transducer_verify_value) {
|
||||||
var separator = "===============================================================";
|
string separator = "===============================================================";
|
||||||
var documentLines = transducer_verify_value.Split(new string[] { Environment.NewLine }, StringSplitOptions.TrimEntries).ToList();
|
List<String> documentLines = transducer_verify_value.Split(new string[] { Environment.NewLine }, StringSplitOptions.TrimEntries).ToList();
|
||||||
|
|
||||||
// Check if proper document
|
// Check if proper document
|
||||||
var title = documentLines[0];
|
string title = documentLines[0];
|
||||||
documentLines.RemoveAt(0);
|
documentLines.RemoveAt(0);
|
||||||
if (title != "|| Transducer Verify Report ||") {
|
if (title != "|| Transducer Verify Report ||") {
|
||||||
throw new Exception("Invalid Transducer Verify Report, please provide a Transducer Verify Report file data");
|
throw new Exception("Invalid Transducer Verify Report, please provide a Transducer Verify Report file data");
|
||||||
}
|
}
|
||||||
|
|
||||||
var countDict = documentLines.GroupBy(p => p).ToDictionary(p => p.Key, q => q.Count());
|
Dictionary<String, int> countDict = documentLines.GroupBy(p => p).ToDictionary(p => p.Key, q => q.Count());
|
||||||
var numTransducers = countDict[separator];
|
int numTransducers = countDict[separator];
|
||||||
var currentTransducer = 0; // ONE BASED - will add 1 later at check step, but first transducer is 1.
|
int currentTransducer = 0; // ONE BASED - will add 1 later at check step, but first transducer is 1.
|
||||||
|
|
||||||
// Find the the indexes of each transducer start and stop
|
// Find the the indexes of each transducer start and stop
|
||||||
for (int i = 0; i < documentLines.Count(); i++) {
|
for (int i = 0; i < documentLines.Count(); i++) {
|
||||||
var line = documentLines[i];
|
string line = documentLines[i];
|
||||||
if (line == $"TRANSDUCER{currentTransducer + 1}") {
|
if (line == $"TRANSDUCER{currentTransducer + 1}") {
|
||||||
currentTransducer++;
|
currentTransducer++;
|
||||||
continue; // Skip TITLE line and separator
|
continue; // Skip TITLE line and separator
|
||||||
@ -66,7 +66,7 @@ namespace BenchtopParser {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Add transducer parameters
|
// Add transducer parameters
|
||||||
var _line = SplitLine(line);
|
string[] _line = SplitLine(line);
|
||||||
if (transducers != null) {
|
if (transducers != null) {
|
||||||
transducers[currentTransducer].parameters[_line[0]] = _line[1];
|
transducers[currentTransducer].parameters[_line[0]] = _line[1];
|
||||||
} else {
|
} else {
|
||||||
|
@ -43,7 +43,7 @@ namespace BenchtopParserTests {
|
|||||||
BenchtopParser.Program program = new();
|
BenchtopParser.Program program = new();
|
||||||
program.AddToGroup(group, config);
|
program.AddToGroup(group, config);
|
||||||
|
|
||||||
var check = program.X["namename"];
|
BenchtopParser.Configuration check = program.X["namename"];
|
||||||
Assert.That(check, Is.EqualTo(config));
|
Assert.That(check, Is.EqualTo(config));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user