コード例 #1
0
        private void FillLines(ref int lineNumberLeft, ref int lineNumberRight)
        {
            for (int i = lineNumberRight; i < lineNumberLeft; i++)
            {
                BranchStringList.Add(i, string.Empty);
                lineNumberRight++;
            }

            for (int i = lineNumberLeft; i < lineNumberRight; i++)
            {
                HeadStringList.Add(i, string.Empty);
                lineNumberLeft++;
            }
        }
コード例 #2
0
        public void ParseToList(string input)
        {
            BranchStringList.Clear();
            HeadStringList.Clear();
            BranchlistValues.Clear();
            HeadlistValues.Clear();

            flag position        = flag.both;
            int  lineNumberLeft  = 0;
            int  lineNumberRight = 0;

            var    stringReader = new StringReader(input);
            string line         = String.Empty;

            while ((line = stringReader.ReadLine()) != null)
            {
                if (line.StartsWith("<<<<<<<"))
                {
                    position = flag.head;
                    continue;
                }
                else if (line.StartsWith("======="))
                {
                    position = flag.branch;
                    continue;
                }
                else if (line.StartsWith(">>>>>>>"))
                {
                    position = flag.both;
                    FillLines(ref lineNumberLeft, ref lineNumberRight);
                    continue;
                }


                if (position == flag.branch)
                {
                    BranchStringList.Add(lineNumberRight, line);
                    lineNumberRight++;
                    HasConflict = true;
                }
                else if (position == flag.head)
                {
                    HeadStringList.Add(lineNumberLeft, line);
                    lineNumberLeft++;
                    HasConflict = true;
                }
                else
                {
                    HeadStringList.Add(lineNumberLeft, line);
                    BranchStringList.Add(lineNumberRight, line);

                    lineNumberLeft++;
                    lineNumberRight++;
                }
            }

            int i = 0;

            foreach (var item in HeadStringList)
            {
                var ct = new ConflictText()
                {
                    LineNumber = i,
                    Text       = item.Value,
                    IsConflict = IsConflict(i++)
                };

                ct.PropertyChanged += Head_PropertyChanged;

                HeadlistValues.Add(ct);
            }
            i = 0;
            foreach (var item in BranchStringList)
            {
                var ct = new ConflictText()
                {
                    LineNumber = i,
                    Text       = item.Value,
                    IsConflict = IsConflict(i++)
                };

                BranchlistValues.Add(ct);

                ct.PropertyChanged += Branch_PropertyChanged;
            }
            FillResultList();
        }