protected void ProcessSection(ControlSection section, StringBuilder templateBuilder, object data, ref int processCount, ref int lengthDifference) { var sectionTextBuilder = new StringBuilder(); var enumerable = GetEnumerableByName(data, section.PropertyName); //var template = new Template(data.GetType(), section.Value); foreach (var item in enumerable) { int i = 0; var itemTextBuilder = new StringBuilder(section.TemplateText); //ProcessMergeItems(item, ref itemTextBuilder, ref processCount, ref i); sectionTextBuilder.Append(itemTextBuilder); } var result = sectionTextBuilder.ToString(); var sectionLengthDiff = (("foreach".Length * 2) + (section.PropertyName.Length * 2) + ("<<>>".Length * 2) + "/".Length); lengthDifference = -sectionLengthDiff; templateBuilder = templateBuilder.Remove(section.Index, section.Length); templateBuilder = templateBuilder.Insert(section.Index, result); }