예제 #1
0
        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();
        }
예제 #2
0
        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);
        }
예제 #3
0
            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};
            }
예제 #4
0
        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();
        }
예제 #5
0
 public SecondarySection(Modification modification, IEnumerable<string> lines, Color color)
     : base(modification, lines, color)
 {
 }
예제 #6
0
 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);
 }
예제 #7
0
파일: Section.cs 프로젝트: gilind/workshop
 protected Section(Modification modification, IEnumerable<string> lines, Color color)
 {
     Modification = modification;
     Color = color;
     Lines = lines == null ? new string[0] : lines.ToArray();
 }
예제 #8
0
 protected override Modification[] DoMerge(Modification other)
 {
     // выходит за рамки задачи
     throw new System.NotImplementedException();
 }
예제 #9
0
        protected virtual Modification[] DoMerge(Modification other)
        {
            if (other.IsNoChanged)
            {
                return new[] {this};
            }

            return new[] {new MixedModification(new[] {this}, new[] {other})};
        }