예제 #1
0
        /// <summary>
        /// Handles the collection of repetitions, adding the data to the model and inserting new elements, as appropriate.
        /// </summary>
        /// <returns>The collection of new rendering contexts which represent new elements added to the DOM.</returns>
        /// <param name="repetitions">The repetitions.</param>
        /// <param name="context">The source rendering context.</param>
        private IRenderingContext[] HandleRepetitions(IRepetitionInfo[] repetitions, IRenderingContext context)
        {
            var output = repetitions
            .Select(x => new { Context = context.CreateSiblingContext(x.AssociatedElement), Repetition = x })
            .ToList();

              var parent = context.Element.GetParentElement();

              foreach(var item in output)
              {
            item.Context.TalModel.AddRepetitionInfo(item.Repetition);

            item.Repetition.AssociatedElement.RemoveAttribute(ZptConstants.Tal.Namespace,
                                                          ZptConstants.Tal.RepeatAttribute);
            parent.InsertBefore(context.Element, item.Repetition.AssociatedElement);
              }

              context.Element.Remove();

              return output
            .Select(x => x.Context)
            .ToArray();
        }
예제 #2
0
파일: Model.cs 프로젝트: csf-dev/ZPT-Sharp
        /// <summary>
        /// Adds information about a repetition to the current instance.
        /// </summary>
        /// <param name="info">The repetition information.</param>
        public virtual void AddRepetitionInfo(IRepetitionInfo info)
        {
            if(info == null)
              {
            throw new ArgumentNullException(nameof(info));
              }

              this.RepetitionInfo = info;
              this.AddLocal(info.Name, info.Value);
        }
 public ModifierRepetitionViewModel(IRepetitionInfo model)
 {
     Repetition = model;
 }