Files
met08ddupsp1tbi/Adaptation/FileHandlers/txt/Header.cs
phares@iscn5cg20977xq 8ee374b2a8 Refactor ProcessDataStandardFormat and add unit tests for v2.61.1
- Updated GetPDSFText method to accept nullable logisticsText parameter.
- Removed unused TryGetPropertyIndex method from ProcessDataStandardFormat.
- Introduced new unit tests for CreateSelfDescription and Extract functionalities in version 2.61.1.
- Implemented logging and file handling in the test classes to ensure proper setup and teardown.
2025-12-02 08:32:55 -07:00

91 lines
2.4 KiB
C#

using System.Text.Json.Serialization;
namespace Adaptation.FileHandlers.txt;
public class Header
{
public Header(string lot,
string session)
{
Lot = lot;
Session = session;
}
public string Lot { get; }
public string Session { get; }
internal static void ScanPast(string text, int[] i, string search)
{
int num = text.IndexOf(search, i[0]);
if (num > -1)
i[0] = num + search.Length;
else
i[0] = text.Length;
}
internal static string GetBefore(string text, int[] i, string search)
{
int num = text.IndexOf(search, i[0]);
if (num > -1)
{
string str = text.Substring(i[0], num - i[0]);
i[0] = num + search.Length;
return str.Trim();
}
string str1 = text.Substring(i[0]);
i[0] = text.Length;
return str1.Trim();
}
internal static string GetBefore(string text, int[] i, string search, bool trim)
{
if (trim)
return GetBefore(text, i, search);
int num = text.IndexOf(search, i[0]);
if (num > -1)
{
string str = text.Substring(i[0], num - i[0]);
i[0] = num + search.Length;
return str;
}
string str1 = text.Substring(i[0]);
i[0] = text.Length;
return str1;
}
internal static string GetToEOL(string text, int[] i) =>
GetBefore(text, i, "\n");
internal static string GetToEOL(string text, int[] i, bool trim)
{
if (trim)
return GetToEOL(text, i);
return GetBefore(text, i, "\n", false);
}
internal static Header Get(Constant constant, int[] i, string text)
{
Header result;
string lot;
string session;
if (!text.Contains(constant.ShortWaferSummary))
ScanPast(text, i, constant.LongWaferSummary);
else
ScanPast(text, i, constant.ShortWaferSummary);
_ = GetToEOL(text, i);
ScanPast(text, i, constant.Session);
session = GetToEOL(text, i, true);
ScanPast(text, i, constant.LotId);
lot = GetToEOL(text, i, true);
result = new(lot, session);
return result;
}
}
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(Header))]
internal partial class HeaderSourceGenerationContext : JsonSerializerContext
{
}