public PrimaryMixedSection(Modification modification, IEnumerable<Modification> firstModifications, Color color) : base(modification, null, color) { List<string> lines = new List<string>(); foreach (Modification firstModification in firstModifications) { lines.AddRange(firstModification.Primary.Lines); } Lines = lines.ToArray(); }
public Modification[] Merge(Modification other) { IList<Modification> result = new List<Modification>(); if (other.Primary.StartIndex != Primary.StartIndex) { result.Add(this); return result.ToArray(); } return DoMerge(other); }
protected override Modification[] DoMerge(Modification other) { IList<Modification> result = new List<Modification>(); if (other.IsAdded) { // отдельная обработка добавленных result.Add(other); if (other.Next != null && ((Modification) other.Next).Primary.StartIndex == Primary.StartIndex) { result.Add((Modification)other.Next); } return result.ToArray(); } return new[] {other}; }
public SecondaryMixedSection(Modification modification, IEnumerable<Modification> firstModifications, IEnumerable<Modification> secondModifications, Color color) : base(modification, null, color) { IList<string> lines = new List<string>(); foreach (Modification firstModification in firstModifications) { foreach (string line in firstModification.Secondary.Lines) { lines.Add("User1:" + line); } } foreach (Modification secondModification in secondModifications) { foreach (string line in secondModification.Secondary.Lines) { lines.Add("User2:" + line); } } Lines = lines.ToArray(); }
public SecondarySection(Modification modification, IEnumerable<string> lines, Color color) : base(modification, lines, color) { }
private static void ModificationAreEqual( Modification modification, string modificationName, int primaryIndex, int secondaryIndex, int length) { Assert.AreEqual(modification.Name, modificationName); //Assert.AreEqual(modification.PrimaryIndex, primaryIndex); //Assert.AreEqual(modification.SecondaryIndex, secondaryIndex); //Assert.AreEqual(modification.Length, length); }
protected Section(Modification modification, IEnumerable<string> lines, Color color) { Modification = modification; Color = color; Lines = lines == null ? new string[0] : lines.ToArray(); }
protected override Modification[] DoMerge(Modification other) { // выходит за рамки задачи throw new System.NotImplementedException(); }
protected virtual Modification[] DoMerge(Modification other) { if (other.IsNoChanged) { return new[] {this}; } return new[] {new MixedModification(new[] {this}, new[] {other})}; }