コード例 #1
0
        private bool DoInstructionInternal(IDetailBlockStart blockStart,
                                           MetadataContextStack contextStack,
                                           List <IDom> newList,
                                           ref IDom lastPart)
        {
            if (blockStart == null)
            {
                return(false);
            }
            var match = blockStartMatch.Match(blockStart.Text);

            if (!match.Success)
            {
                return(false);
            }

            var         varName           = match.Groups[varNameKey].Value;
            var         loopOver          = match.Groups[loopOverKey].Value;
            IEnumerable propAsIEnumerable = GetPropList(contextStack, loopOver);
            var         blockContents     = blockStart.BlockContents;

            foreach (var item in propAsIEnumerable)
            {
                contextStack.Push(varName, item);
                Helper.RunOneLoop(blockContents, blockStart, contextStack, newList);
                contextStack.Pop();
            }
            lastPart = blockStart.BlockEnd;
            return(true);
        }
        public IEnumerable <IRoot> Run <TMetadata>(TMetadata metadata)
        {
            contextStack.Push(Constants.Metadata, metadata);
            contextStack.Add(Constants.ExpansionFirstRunner, this);
            var thisRoot = templateRoot.Copy();

            DoTemplateStart(thisRoot);
            IDom nextPart = null;
            var  retList  = Update(thisRoot, contextStack, ref nextPart).Cast <IRoot>();

            DoTemplateComplete(thisRoot, retList);
            contextStack.Pop();
            return(retList);
        }