Exemplo n.º 1
0
        public string Evaluate(TagModel model)
        {
            var    builder   = new StringBuilder();
            IList  list      = ToList(GetIEnumerable(model));
            int    start     = GetAutoValueAsInt("Begin", model).Value;
            int    end       = GetAsInt(End, model) ?? list.Count;
            int    step      = GetAutoValueAsInt("Step", model).Value;
            string var       = GetAutoValueAsString("Var", model);
            string varStatus = GetAutoValueAsString("VarStatus", model);

            model.PushTagStack(true);
            var status = new ForEachStatus(list.Count, start, end);

            if (list.Count > 0)
            {
                model.Tag[varStatus] = status;
                for (int i = start; i < end; i += step)
                {
                    status.Index   = i;
                    model.Tag[var] = list[i];
                    builder.Append(GetAsString(Body, model) ?? String.Empty);
                }
                model.Tag[var]       = null;
                model.Tag[varStatus] = null;
            }
            model.PopTagStack();
            return(builder.ToString());
        }
Exemplo n.º 2
0
 public string Evaluate(TagModel model)
 {
     var builder = new StringBuilder();
     IList list = ToList(GetIEnumerable(model));
     int start = GetAutoValueAsInt("Begin", model).Value;
     int end = GetAsInt(End, model) ?? list.Count;
     int step = GetAutoValueAsInt("Step", model).Value;
     string var = GetAutoValueAsString("Var", model);
     string varStatus = GetAutoValueAsString("VarStatus", model);
     model.PushTagStack();
     var status = new ForEachStatus(list.Count, start, end);
     if (list.Count > 0)
     {
         model.Tag[varStatus] = status;
         for (int i = start; i < end; i += step)
         {
             status.Index = i;
             model.Tag[var] = list[i];
             builder.Append(GetAsString(Body, model) ?? String.Empty);
         }
         model.Tag[var] = null;
         model.Tag[varStatus] = null;
     }
     model.PopTagStack();
     return builder.ToString();
 }