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