public static bool ContainsLine(this LinkEntry Entry, uint Line) => Entry.LinkInfo.ContainsLine(Line);
public static bool IsLineLink(this LinkEntry Entry) => Entry.LinkInfo.IsLineLink();
LinkEntry[] ParseLinks() { List <string> ParsedSpts = new List <string>(); List <LinkEntry> Entries = new List <LinkEntry>(); foreach (var Block in GetBlocks()) { var LblParts = Block.Label.Split('_'); var SptList = new List <string>(); if (Block.Label.Substring(0, 2) == "SC") //SC_A0100_00_A0110_00 { var FileA = $"{LblParts[1]}_{LblParts[2]}.spt"; var FileB = $"{LblParts[3]}_{LblParts[4]}.spt"; if (!File.Exists(WorkDir + FileA)) { throw new FileNotFoundException(FileA); } //if (!File.Exists(WorkDir + FileB)) // throw new FileNotFoundException(FileB); SptList.Add(FileA); //SptList.Add(FileB); } else if (Block.Label.Substring(0, 2) == "SS") //SS_A0010_30_02_40_50 { string Base = LblParts[1]; var FileName = $"{Base}_{LblParts[2]}.spt"; if (!File.Exists(WorkDir + FileName)) { throw new FileNotFoundException(FileName); } SptList.Add(FileName); foreach (var Part in LblParts.Skip(4)) { FileName = $"{Base}_{Part}.spt"; if (!File.Exists(WorkDir + FileName)) { throw new FileNotFoundException(FileName); } SptList.Add(FileName); } } else { throw new NotImplementedException(Block.Label.Substring(0, 2) + " Label not supported."); } SptList = SptList.Distinct().ToList(); SptList = new List <string>((from x in SptList where !ParsedSpts.Contains(x) select x).ToArray()); ParsedSpts.AddRange(SptList); foreach (string File in SptList) { var SPTData = new SPTFormat(); using (StructReader Reader = new StructReader(WorkDir + File)) Reader.ReadStruct(ref SPTData); List <LinkEntry> Links = new List <LinkEntry>(); foreach (var Info in SPTData.Entries) { LinkEntry Entry = new LinkEntry(); Entry.Lines = new string[0]; if (Info.IsLineLink()) { // if (!Block.ContainsLine(Info.Line)) // continue; string[] Lines = new string[Info.Count]; for (int i = 0; i < Lines.Length; i++) { Lines[i] = Script[Info.Line + i]; } Entry.Lines = Lines; } Entry.LinkInfo = Info; Entry.SPTName = File; Links.Add(Entry); } Entries.AddRange(Links); } } int SPTs = (from x in Entries select x.SPTName).Distinct().Count(); return(Entries.ToArray()); }