Spreading Resistance Profile with ChartJS,
Copy-On-Get and nuget bump (Serilog)
This commit is contained in:
80
Server/Services/csv/LayerHeader.cs
Normal file
80
Server/Services/csv/LayerHeader.cs
Normal file
@ -0,0 +1,80 @@
|
||||
using System.Text;
|
||||
|
||||
namespace Adaptation.FileHandlers.csv;
|
||||
|
||||
public class LayerHeader
|
||||
{
|
||||
|
||||
#nullable disable
|
||||
|
||||
public string NumberOfLayers { get; set; }
|
||||
public List<Layer> Layers { get; set; }
|
||||
|
||||
#nullable enable
|
||||
#pragma warning disable CA1834
|
||||
|
||||
internal static LayerHeader? GetLayerHeader(string[] lines, int start, int stop)
|
||||
{
|
||||
LayerHeader? result;
|
||||
Layer layer;
|
||||
string first;
|
||||
string[] segments;
|
||||
int? secondStart = null;
|
||||
List<Layer> layerCollection = new();
|
||||
List<string> values = new();
|
||||
StringBuilder stringBuilder = new();
|
||||
for (int i = start; i < stop; i++)
|
||||
{
|
||||
segments = lines[i].Split(new string[] { "," }, StringSplitOptions.None);
|
||||
first = segments.First();
|
||||
if (first == "Layer")
|
||||
{
|
||||
secondStart = i + 1;
|
||||
break;
|
||||
}
|
||||
_ = stringBuilder.Append(first).Append(",");
|
||||
if (segments.Length > 1)
|
||||
values.Add(segments[1]);
|
||||
else
|
||||
values.Add(string.Empty);
|
||||
}
|
||||
string header = "Number of Layers,";
|
||||
if (secondStart is null || stringBuilder.Length != header.Length || stringBuilder.ToString() != header)
|
||||
result = null;
|
||||
else
|
||||
{
|
||||
result = new()
|
||||
{
|
||||
NumberOfLayers = values[0],
|
||||
Layers = layerCollection,
|
||||
};
|
||||
for (int i = secondStart.Value; i < stop; i++)
|
||||
{
|
||||
segments = lines[i].Split(new string[] { "," }, StringSplitOptions.None);
|
||||
if (segments.Length < 15)
|
||||
continue;
|
||||
layer = new()
|
||||
{
|
||||
FirstPoint = segments[0],
|
||||
LastPoint = segments[1],
|
||||
Type = segments[2],
|
||||
Smoothing = segments[3],
|
||||
Apply = segments[4],
|
||||
SOrder = segments[5],
|
||||
GOrder = segments[6],
|
||||
Correction = segments[7],
|
||||
Conversion = segments[8],
|
||||
JunctionOption = segments[9],
|
||||
JunctionConstant = segments[10],
|
||||
CurrentDensity = segments[11],
|
||||
M1M2Tolerance = segments[12],
|
||||
Sheet = segments[13],
|
||||
Dose = segments[14],
|
||||
};
|
||||
layerCollection.Add(layer);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user