Exemplo n.º 1
0
        public override void Render(System.IO.TextWriter writer)
        {
            if (string.IsNullOrEmpty(this.Group))
            {
                return;
            }

            IEnumerable friendList = MyDataContext.GetEnumerableVariableObject(this.Group);

            if (null == friendList)
            {
                return;
            }

            string output = string.Empty;

            if (!MultiSelect)
            {
                output = singleSelectDropDown(friendList);
            }
            else
            {
                output = multiSelectDropDown(friendList);
            }

            writer.Write(output);
        }
Exemplo n.º 2
0
        public override void Render(System.IO.TextWriter writer)
        {
            IEnumerable simpleList = MyDataContext.GetEnumerableVariableObject(RepeatedDataKey);

            if (null == simpleList)
            {
                return;
            }

            //TODO - hunt down why repeat nested in templates not parsed.
            if (Controls.Count == 0 && MyOffset.ChildOffsets.Count > 0)
            {
                BuildControlTreeFromOffsets();
            }


            bool hasPrequel = (!string.IsNullOrEmpty(LoopPrequel));
            bool hasSequel  = (!string.IsNullOrEmpty(LoopSequel));


            //System.Collections.Hashtable
            LoopContext context = new LoopContext(0, 0);

            //resolve the count
            if (simpleList is IList)
            {
                context.Count = ((IList)simpleList).Count;
            }
            else
            {
                //enumerate to count items
                int count = 0;
                foreach (object item in simpleList)
                {
                    count++;
                }
                context.Count = count;
            }
            //saftey check on LoopContextVariableKey
            if (string.IsNullOrEmpty(LoopContextVariableKey))
            {
                LoopContextVariableKey = "Context";
            }


            foreach (object item in simpleList)
            {
                object realItem = item;
                if (item is DictionaryEntry)
                {
                    realItem = ((DictionaryEntry)item).Value;
                }
                MyDataContext.RegisterLocalValue(this.LoopItemKey, realItem);

                if (MyDataContext.HasVariable(this.LoopContextVariableKey))
                {
                    MyDataContext.RemoveLocalValue(this.LoopContextVariableKey);
                }
                MyDataContext.RegisterLocalValue(this.LoopContextVariableKey, context);

                //Evaluate any conditionals
                if (EvaluateLoopConditionalExpressionPasses())
                {
                    if (hasPrequel)
                    {
                        writer.Write(MyDataContext.ResolveVariables(LoopPrequel));
                    }

                    RenderTemplateInstance(writer);

                    if (hasSequel)
                    {
                        writer.Write(MyDataContext.ResolveVariables(LoopSequel));
                    }
                }
                context.Index++;
                MyDataContext.RemoveLocalValue(this.LoopItemKey);
            }
            //remove the final context variable
            if (MyDataContext.HasVariable(this.LoopContextVariableKey))
            {
                MyDataContext.RemoveLocalValue(this.LoopContextVariableKey);
            }
        }