Files
C4IT-F4SD-Client/F4SD-Docu-Engine/DocuEngineParser/ContentBlock/ContentBlockForeachCommand.cs
Meik 0b52999b1d feat: expand cockpit integrations and support workflows
Add Phoenix remote desktop, action connector, documentation engine, and gamification support. Refactor support-case processing and search/action UI, and update installer assets and dependencies.
2026-07-13 11:16:53 +02:00

53 lines
2.0 KiB
C#

using F4SD.DocuEngine.DocuEngineDataProvider;
using F4SD.DocuEngine.DocuEngineParser.Exceptions;
using System.ComponentModel;
using System.Linq;
namespace F4SD.DocuEngine.DocuEngineParser.ContentBlock
{
internal partial class ContentBlock
{
private void ParseForeachCommand(ref int index)
{
string variableName = "";
string enumName = "";
int tempIndex = 0;
SkipWhiteSpace(ref index);
variableName += ParseVariableName(ref index);
SkipWhiteSpace(ref index);
if (!(DocuTemplate.ElementAtOrDefault(index).Equals(';')))
{
throw new SyntaxErrorException(";", DocuTemplate.ElementAtOrDefault(index).ToString());
}
index++;
SkipWhiteSpace(ref index);
enumName += ParseVariableName(ref index);
SkipWhiteSpace(ref index);
if (!(DocuTemplate.ElementAtOrDefault(index).Equals(')')))
{
throw new SyntaxErrorException(")", DocuTemplate.ElementAtOrDefault(index).ToString());
}
index++;
SkipWhiteSpace(ref index);
if (!DocuTemplate.Substring(index, 2).Equals("{{"))
{
throw new SyntaxErrorException("{{", DocuTemplate.Substring(index, 2));
}
index += 2;
IDocuEngineDataEnumeration enumeration = Container.GetEnumerationByName(enumName);
if (enumeration == null)
{
//Syntax Error
}
tempIndex = index;
foreach (var token in enumeration)
{
index = tempIndex;
ContentBlock foreachBlock = new ContentBlock(DocuTemplate, new DocuEngineDataContainer() { { variableName, token } });
parsingContext.Append(foreachBlock.ParseContentBlock(ref index));
}
}
}
}