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)); } } } }