示例#1
0
        static Foreach()
        {
            SectionNames = ForeachSectionEnum.GetNames(typeof(ForeachSectionEnum));

            Array.Sort(SectionNames, CaseInsensitiveComparer.Default);

            for (int i = 0; i < SectionNames.Length; i++)
            {
                SectionNames[i] = SectionNames[i].ToLower();
            }
        }
示例#2
0
 private void ProcessSection(ForeachSectionEnum sectionEnumType, INode[][] sections, IInternalContextAdapter context, TextWriter writer)
 {
     if (sections[(int)sectionEnumType] != null)
     {
         INode[] array = sections[(int)sectionEnumType];
         for (int i = 0; i < array.Length; i++)
         {
             INode node = array[i];
             node.Render(context, writer);
         }
     }
 }
示例#3
0
        private INode[][] PrepareSections(INode node)
        {
            bool isFancyLoop = false;

            int curSection = (int)ForeachSectionEnum.Each;

            ArrayList[] sections = new ArrayList[SectionNames.Length];

            int nodeCount = node.ChildrenCount;

            for (int i = 0; i < nodeCount; i++)
            {
                INode        childNode = node.GetChild(i);
                ASTDirective directive = childNode as ASTDirective;

                if (directive != null && Array.BinarySearch(SectionNames, directive.DirectiveName) > -1)
                {
                    isFancyLoop = true;
                    curSection  = (int)ForeachSectionEnum.Parse(
                        typeof(ForeachSectionEnum), directive.DirectiveName, true);
                }
                else
                {
                    if (sections[curSection] == null)
                    {
                        sections[curSection] = new ArrayList();
                    }
                    sections[curSection].Add(childNode);
                }
            }

            if (!isFancyLoop)
            {
                return(null);
            }
            else
            {
                INode[][] result = new INode[sections.Length][];

                for (int i = 0; i < sections.Length; i++)
                {
                    if (sections[i] != null)
                    {
                        result[i] = sections[i].ToArray(typeof(INode)) as INode[];
                    }
                }

                return(result);
            }
        }
示例#4
0
        private void ProcessSection(ForeachSectionEnum sectionEnumType, INode[][] sections, IInternalContextAdapter context,
                                    TextWriter writer)
        {
            int sectionIndex = (int)sectionEnumType;

            if (sections[sectionIndex] == null)
            {
                return;
            }

            foreach (INode node in sections[sectionIndex])
            {
                node.Render(context, writer);
            }
        }
示例#5
0
        private void ProcessSection(ForeachSectionEnum sectionEnumType, INode[][] sections, IInternalContextAdapter context,
                                    TextWriter writer)
        {
            int sectionIndex = (int)sectionEnumType;

            if (sections[sectionIndex] == null)
            {
                return;
            }

            foreach (INode node in sections[sectionIndex])
            {
                node.Render(context, writer);
            }
        }