public void CloneTest() { GroupBy groupBy = new GroupBy(); groupBy.By = ElementAttributeType.Name; groupBy.AttributeCapture = "(.*)"; groupBy.CustomSeparator = "\r\nXXX\r\n"; groupBy.Direction = SortDirection.Descending; groupBy.SeparatorType = GroupSeparatorType.Custom; GroupBy innerGroupBy = new GroupBy(); innerGroupBy.By = ElementAttributeType.Type; groupBy.InnerGroupBy = innerGroupBy; GroupBy clone = groupBy.Clone() as GroupBy; Assert.AreEqual(groupBy.By, clone.By, "By was not copied correctly"); Assert.AreEqual(groupBy.AttributeCapture, clone.AttributeCapture, "AttributeCapture was not copied correctly"); Assert.AreEqual(groupBy.CustomSeparator, clone.CustomSeparator, "CustomSeparator was not copied correctly"); Assert.AreEqual(groupBy.Direction, clone.Direction, "Direction was not copied correctly"); Assert.AreEqual(groupBy.SeparatorType, clone.SeparatorType, "SeparatorType was not copied correctly"); Assert.IsNotNull(clone.InnerGroupBy, "InnerGroupBy was not copied correctly"); Assert.AreEqual(groupBy.InnerGroupBy.By, clone.InnerGroupBy.By, "InnerGroupBy was not copied correctly"); }
/// <summary> /// Creates a new GroupedInserter using the specified grouping configuration /// and sorter. /// </summary> /// <param name="groupBy">The group by.</param> /// <param name="innerInserter">The inner inserter.</param> public GroupedInserter(GroupBy groupBy, IElementInserter innerInserter) { if (groupBy == null) { throw new ArgumentNullException("groupBy"); } _groupBy = groupBy.Clone() as GroupBy; _innerInserter = innerInserter; if (!string.IsNullOrEmpty(groupBy.AttributeCapture)) { _captureRegex = new Regex(_groupBy.AttributeCapture); } }