Exemplo n.º 1
0
 public DiffEventArgs(DiffType diffType, T lineValue, int leftIndex, int rightIndex)
 {
     this.DiffType   = diffType;
     this.LineValue  = lineValue;
     this.LeftIndex  = leftIndex;
     this.RightIndex = rightIndex;
 }
 public DiffEventArgs(DiffType diffType, T lineValue, int leftIndex, int rightIndex)
 {
     DiffType   = diffType;
     LineValue  = lineValue;
     LeftIndex  = leftIndex;
     RightIndex = rightIndex;
 }
Exemplo n.º 3
0
 public DiffItem(DiffType diff, ContentType type, string sheet, ExcelRange range)
 {
     this.Sheet = sheet;
     this.Diff  = diff;
     this.Type  = type;
     this.Range = range;
 }
Exemplo n.º 4
0
        private static void WriteLine(int nr, DiffType typ, string aText, StringBuilder diffText, bool numberLines)
        {
            diffText.Append("<tr><td>");
            if (nr >= 0 && numberLines)
            {
                diffText.Append((nr).ToString());
            }
            else
            {
                diffText.Append("&nbsp;");
            }
            diffText.Append("<td><span xstyle='width:100%'");

            switch (typ)
            {
            case DiffType.None:
                break;

            case DiffType.Deleted:
                diffText.Append(" style='background-color: red; width: 100%;'");
                break;

            case DiffType.Inserted:
                diffText.Append(" style='background-color: green; width: 100%'");
                break;

            default:
                break;
            }


            aText = HttpUtility.HtmlEncode(aText).Replace("\r", "").Replace(" ", "&nbsp;");
            diffText.Append(">" + aText + "</span></td></tr>\n");
        }
Exemplo n.º 5
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (UserId != 0)
            {
                hash ^= UserId.GetHashCode();
            }
            if (ActivityId != 0)
            {
                hash ^= ActivityId.GetHashCode();
            }
            if (MusicId != 0)
            {
                hash ^= MusicId.GetHashCode();
            }
            if (DiffType != 0)
            {
                hash ^= DiffType.GetHashCode();
            }
            if (MaxScore != 0)
            {
                hash ^= MaxScore.GetHashCode();
            }
            return(hash);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Class constructor
 /// </summary>
 /// <param name="itemA">Is either a path to the left text A or the text itself directly.
 /// The interpretation of the string content depends on the setting in <paramref name="diffType"/>.
 /// </param>
 /// <param name="itemB">Is either a path to the right text B or the text itself directly.
 /// The interpretation of the string content depends on the setting in <paramref name="diffType"/>.
 /// </param>
 /// <param name="diffType">This should be either set to <see cref="DiffType.File"/> or <see cref="DiffType.Text"/>
 /// to interprete values in <paramref name="itemA"/> and <paramref name="itemB"/> either as file
 /// based input or direct string based input.</param>
 public TextBinaryDiffArgs(string itemA, string itemB, DiffType diffType)
     : this()
 {
     this.A        = itemA;
     this.B        = itemB;
     this.DiffType = diffType;
 }
Exemplo n.º 7
0
 public PackageKeyDiff(DiffType diffType, PackageKey newPackageKey, PackageKey oldPackageKey, RepositoryType packageType)
     : base(newPackageKey.PackageId, newPackageKey.Version, newPackageKey.Framework)
 {
     DiffType      = diffType;
     OldPackageKey = oldPackageKey;
     PackageType   = packageType;
 }
Exemplo n.º 8
0
        public DiffFile(string fileName, DiffType type)
        {
            m_xpatches = new Dictionary <int, DiffPatchBase>();
            m_patches  = new Dictionary <string, DiffPatch>();

            this.Load(fileName, type);
        }
Exemplo n.º 9
0
 /// <summary>
 /// Class constructor
 /// </summary>
 /// <param name="itemA"></param>
 /// <param name="itemB"></param>
 /// <param name="diffType"></param>
 /// <param name="spacesPerTab"></param>
 public TextBinaryDiffArgs(string itemA, string itemB, DiffType diffType, int spacesPerTab)
     : this()
 {
     this.A            = itemA;
     this.B            = itemB;
     this.DiffType     = diffType;
     this.SpacesPerTab = spacesPerTab;
 }
Exemplo n.º 10
0
        /// <summary>Create <see cref="Diff"/>.</summary>
        /// <param name="type">Diff type.</param>
        /// <param name="files">List of file diffs.</param>
        public Diff(DiffType type, IList <DiffFile> files)
        {
            Verify.Argument.IsNotNull(files, "files");
            Verify.Argument.HasNoNullItems(files, "files");

            _type  = type;
            _files = files;
        }
Exemplo n.º 11
0
 public FileDiff(string oldDir, string newDir, string fileName, DiffType diffType, string diff)
 {
     OldDir   = oldDir;
     NewDir   = newDir;
     FileName = fileName;
     DiffType = diffType;
     Diff     = diff;
 }
Exemplo n.º 12
0
 public DiffSection(DiffType type, int oldIndex, T oldItem, int newIndex, T newItem)
 {
     Type     = type;
     OldIndex = oldIndex;
     OldItem  = oldItem;
     NewIndex = newIndex;
     NewItem  = newItem;
 }
 internal ArtifactInfoDifference(string key, DiffType diffType, ArtifactInfo oldArtifactInfo, ArtifactInfo newArtifactInfo)
 {
     this.key             = key;
     this.diffType        = diffType;
     this.oldArtifactInfo = oldArtifactInfo;
     this.newArtifactInfo = newArtifactInfo;
     this.message         = "";
 }
 internal ArtifactInfoDifference(ArtifactInfoDifference other)
 {
     this.key             = other.key;
     this.diffType        = other.diffType;
     this.oldArtifactInfo = other.oldArtifactInfo;
     this.newArtifactInfo = other.newArtifactInfo;
     this.message         = other.message;
 }
Exemplo n.º 15
0
        private IDiffResult DiffResultFactory(DiffType type, IDictionary <int, List <Diff> > diffs)
        {
            Type objtype = Assembly.GetExecutingAssembly().GetTypes().First(x => x.GetCustomAttribute <DiffTypeAttribute>()?.DiffType == type);
            var  flags   = BindingFlags.NonPublic | BindingFlags.Instance;

            object[] args = new object[] { PreviousDB, CurrentDB, diffs };

            return((IDiffResult)Activator.CreateInstance(objtype, flags, null, args, null));
        }
Exemplo n.º 16
0
 /// <summary>
 /// Class constructor
 /// </summary>
 /// <param name="itemA">Is either a path to the left text A or the text itself directly.
 /// The interpretation of the string content depends on the setting in <paramref name="diffType"/>.
 /// </param>
 /// <param name="itemB">Is either a path to the right text B or the text itself directly.
 /// The interpretation of the string content depends on the setting in <paramref name="diffType"/>.
 /// </param>
 /// <param name="diffType">This should be either set to <see cref="DiffType.File"/> or <see cref="DiffType.Text"/>
 /// to interprete values in <paramref name="itemA"/> and <paramref name="itemB"/> either as file
 /// based input or direct string based input.</param>
 /// <param name="spacesPerTab">number of spaces that should be applied to a TAB character.</param>
 public TextBinaryDiffArgs(string itemA, string itemB, DiffType diffType, int spacesPerTab, bool reloadFromFile)
     : this()
 {
     this.A              = itemA;
     this.B              = itemB;
     this.DiffType       = diffType;
     this.SpacesPerTab   = spacesPerTab;
     this.ReloadFromFile = reloadFromFile;
 }
Exemplo n.º 17
0
        public DiffInstance(string aDifference, string aSection, DiffType aDiffType, List <string> aDetails, DateTime aSnapshotCreationDate)
        {
            Section    = aSection;
            difference = aDifference;
            diffType   = aDiffType;
            details    = aDetails;

            snapshotCreationDate = aSnapshotCreationDate;
        }
Exemplo n.º 18
0
 public DiffResult(int index, DiffType diffType, DiffSentence main, DiffSentence sub, List <string> sameTexts, List <string> modifiedTexts)
 {
     this.Index         = index;
     this.DiffType      = diffType;
     this.Main          = main;
     this.Sub           = sub;
     this.SameTexts     = sameTexts;
     this.ModifiedTexts = modifiedTexts;
 }
Exemplo n.º 19
0
        public DiffGridModel(ExcelSheetDiff sheetDiff, DiffType type) : base()
        {
            DiffType  = type;
            SheetDiff = sheetDiff;

            columnCount = SheetDiff.Rows.Any() ? SheetDiff.Rows.Max(r => r.Value.Cells.Count) : 0;
            rowCount    = SheetDiff.Rows.Count();

            App.Instance.OnSettingUpdated += () => { InvalidateAll(); };
        }
Exemplo n.º 20
0
        public void ShowDifferences(ShowDiffArgs e)
        {
            string   textA    = e.A;
            string   textB    = e.B;
            DiffType diffType = e.DiffType;

            IList <string> a, b;
            int            leadingCharactersToIgnore = 0;
            bool           fileNames = diffType == DiffType.File;

            if (fileNames)
            {
                GetFileLines(textA, textB, out a, out b, out leadingCharactersToIgnore);
            }
            else
            {
                GetTextLines(textA, textB, out a, out b);
            }

            bool       isBinaryCompare      = leadingCharactersToIgnore > 0;
            bool       ignoreCase           = isBinaryCompare ? false : Options.IgnoreCase;
            bool       ignoreTextWhitespace = isBinaryCompare ? false : Options.IgnoreTextWhitespace;
            TextDiff   diff   = new TextDiff(Options.HashType, ignoreCase, ignoreTextWhitespace, leadingCharactersToIgnore, !Options.ShowChangeAsDeleteInsert);
            EditScript script = diff.Execute(a, b);

            string captionA = string.Empty;
            string captionB = string.Empty;

            if (fileNames)
            {
                captionA  = textA;
                captionB  = textB;
                this.Text = string.Format("{0} : {1}", Path.GetFileName(textA), Path.GetFileName(textB));
            }
            else
            {
                this.Text = "Text Comparison";
            }

            // Apply options first since SetData needs to know things
            // like SpacesPerTab and ShowWhitespace up front, so it
            // can build display lines, determine scroll bounds, etc.
            this.ApplyOptions();

            this.DiffCtrl.SetData(a, b, script, captionA, captionB, ignoreCase, ignoreTextWhitespace, isBinaryCompare);

            if (Options.LineDiffHeight != 0)
            {
                this.DiffCtrl.LineDiffHeight = Options.LineDiffHeight;
            }

            this.Show();

            this.currentDiffArgs = e;
        }
Exemplo n.º 21
0
        /// <summary>
        /// Constructs a diff item.
        /// </summary>
        /// <param name="diffType">The type of the diff.</param>
        /// <param name="path">The path of the difference.</param>
        /// <param name="targets">Indicates which XML fragment is targeted by the diff.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="diffType"/> or <paramref name="path"/> is null.</exception>
        /// <exception cref="ArgumentException">Thrown if <paramref name="diffType"/> or <paramref name="path"/> is empty.</exception>
        public Diff(DiffType diffType, IXmlPathStrict path, DiffTargets targets)
        {
            if (diffType == null)
                throw new ArgumentNullException("diffType");
            if (path == null)
                throw new ArgumentNullException("path");

            this.diffType = diffType;
            this.path = path;
            this.targets = targets;
        }
Exemplo n.º 22
0
        /// <summary>Read git diff.</summary>
        /// <param name="type">Diff type.</param>
        /// <returns>Parsed <see cref="Diff"/>.</returns>
        public Diff ReadDiff(DiffType type)
        {
            FindStartOfLine(FileHeader);
            var files = new List <DiffFile>();

            while (!IsAtEndOfString)
            {
                files.Add(ReadDiffFile());
            }
            return(new Diff(type, files));
        }
Exemplo n.º 23
0
        public void TypeTest()
        {
            DiffType expected = DiffType.FileType;

            setTarget();
            Assert.AreEqual(target.Type, DiffType.Content);
            target.Type = expected;
            DiffType actual = target.Type;

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 24
0
 public DepotFileDiff(DiffType type,
                      FileSpec leftfile,
                      FileSpec rightfile,
                      string diff
                      )
 {
     Type      = type;
     LeftFile  = leftfile;
     RightFile = rightfile;
     Diff      = diff;
 }
Exemplo n.º 25
0
        private void FireLineUpdate(DiffType diffType, T lineValue)
        {
            var local = this.LineUpdate;

            if (local == null)
            {
                return;
            }

            local(this, new DiffEventArgs <T>(diffType, lineValue));
        }
Exemplo n.º 26
0
            public void ReportDiff(DiffType tp, string fname, string text, Result docResult = null, Exception error = null)
            {
                var diff = new Diff
                {
                    Type      = tp,
                    FieldName = fname,
                    Text      = text,
                    DocResult = docResult,
                    Error     = error
                };

                m_Diffs.Add(diff);
            }
            private void FireLineUpdate(DiffType diffType, int leftIndex, int rightIndex)
            {
                var local = LineUpdate;

                if (local == null)
                {
                    return;
                }

                var lineValue = leftIndex >= 0 ? _left[leftIndex] : _right[rightIndex];

                local(this, new DiffEventArgs <T>(diffType, lineValue, leftIndex, rightIndex));
            }
Exemplo n.º 28
0
        public DiffGridModel(DiffType type, ExcelSheetDiff sheetDiff, DiffGridModelConfig config) : base()
        {
            SheetDiff         = sheetDiff;
            Config            = config;
            ColumnHeaderIndex = Config.ColumnHeaderIndex;
            RowHeaderIndex    = Config.RowHeaderIndex;
            DiffType          = type;

            columnCount = SheetDiff.Rows.Max(r => r.Value.Cells.Count);
            rowCount    = SheetDiff.Rows.Count();

            App.Instance.OnSettingUpdated += () => { NotifyRefresh(); };
        }
Exemplo n.º 29
0
        private void ShowDifferences(string itemA, string itemB, DiffType diffType)
        {
            using (WaitCursor wc = new WaitCursor(this))
            {
                try
                {
                    Form frmNew;
                    if (diffType == DiffType.Directory)
                    {
#pragma warning disable CA2000 // Dispose objects before losing scope. This modeless form is owned by the MDI parent window.
                        frmNew = new DirDiffForm();
#pragma warning restore CA2000 // Dispose objects before losing scope
                        this.RecentDirs.Add(BuildRecentItemMenuString(itemA, itemB), new string[] { itemA, itemB });
                    }
                    else
                    {
                        // Use a FileDiffForm for file or text diffs.
#pragma warning disable CA2000 // Dispose objects before losing scope. This modeless form is owned by the MDI parent window.
                        frmNew = new FileDiffForm();
#pragma warning restore CA2000 // Dispose objects before losing scope

                        if (diffType == DiffType.File)
                        {
                            this.RecentFiles.Add(BuildRecentItemMenuString(itemA, itemB), new string[] { itemA, itemB });
                        }
                    }

                    if (this.NewChildShouldBeMaximized)
                    {
                        frmNew.WindowState = FormWindowState.Maximized;
                    }

                    frmNew.MdiParent = this;

                    IDifferenceForm frmDiff = (IDifferenceForm)frmNew;
                    frmDiff.ShowDifferences(new ShowDiffArgs(itemA, itemB, diffType));

                    MdiTab tab = this.mdiTabStrip.FindTab(frmNew);
                    if (tab != null)
                    {
                        tab.ToolTipText = frmDiff.ToolTipText;
                    }
                }
                catch (Exception ex)
                {
                    this.ReportError(ex.Message);
                }
            }
        }
Exemplo n.º 30
0
        public static Color GetColor(DiffType type)
        {
            switch (type)
            {
            case DiffType.Added:
                return(Color.Cyan);

            case DiffType.Deleted:
                return(Color.Red);

            case DiffType.Modified:
                return(Color.Yellow);
            }

            return(Color.White);
        }
Exemplo n.º 31
0
        private string GetDiffType(DiffType type)
        {
            switch (type)
            {
            case DiffType.None:
                return(string.Empty);

            case DiffType.Element:
                return("1");

            case DiffType.Whitespace:
                return("2");

            case DiffType.Comment:
                return("3");

            case DiffType.PI:
                return("4");

            case DiffType.Text:
                return("5");

            case DiffType.Attribute:
                return("6");

            case DiffType.NS:
                return("7");

            case DiffType.Prefix:
                return("8");

            case DiffType.SourceExtra:
                return("9");

            case DiffType.TargetExtra:
                return("10");

            case DiffType.NodeType:
                return("11");

            case DiffType.CData:
                return("12");

            default:
                return(string.Empty);
            }
        }
Exemplo n.º 32
0
        /// <summary>Create <see cref="FileDiffPanel"/>.</summary>
        public FileDiffPanel(Repository repository, DiffFile diffFile, DiffType diffType)
        {
            Verify.Argument.IsNotNull(diffFile, "diffFile");

            _repository = repository;
            _diffType = diffType;
            _diffFile = diffFile;
            if(_diffFile.HunkCount != 0)
            {
                _digits = GetDecimalDigits(_diffFile.MaxLineNum);
                _columnWidth = _lineHeaderWidth = _digits * CellSize.Width;
                _lineHeaderWidth *= _diffFile[0].ColumnCount;
            }
            else
            {
                _digits = 0;
                _columnWidth = 0;
                _lineHeaderWidth = 0;
            }
            _lineHover = new TrackingService(OnLineHoverChanged);
            _selStart = -1;
            _selEnd = -1;
            _selOrigin = -1;
        }
Exemplo n.º 33
0
 public DataTableRow(List<Comment> comments, List<String> cells, int line, DiffType diffType)
     : base(comments, cells, line)
 {
     this.diffType = diffType;
 }
Exemplo n.º 34
0
 /// <summary>Read git diff.</summary>
 /// <param name="type">Diff type.</param>
 /// <returns>Parsed <see cref="Diff"/>.</returns>
 public Diff ReadDiff(DiffType type)
 {
     FindStartOfLine(FileHeader);
     var files = new List<DiffFile>();
     while(!IsAtEndOfString)
     {
         files.Add(ReadDiffFile());
     }
     return new Diff(type, files);
 }
Exemplo n.º 35
0
        private void DrawTree(DiffType filter)
        {
            treeSource.BeginUpdate();
            treeDestination.BeginUpdate();

            if (differences != null)
            {
                treeSource.Nodes.Clear();
                treeSource.Nodes.Add(MakeTreeFromPaths(differences, filter, "Source Files", source: true));
                treeSource.Sort();
                //treeSource.ExpandAll();

                treeDestination.Nodes.Clear();
                treeDestination.Nodes.Add(MakeTreeFromPaths(differences, filter, "Destination Files", source: false));
                treeDestination.Sort();
                //treeDestination.ExpandAll();
            }

            treeSource.EndUpdate();
            treeDestination.EndUpdate();
        }
Exemplo n.º 36
0
        private TreeNode MakeTreeFromPaths(List<FileDiff> paths, DiffType filter, string rootNodeName = "", char separator = '\\', bool source = true)
        {
            var rootNode = new TreeNode(rootNodeName);
            var allpaths = source ? paths.Where(x => x.Source != null) : paths.Where(x => x.Destination != null);

            foreach (var path in allpaths)
            {
                var currentNode = rootNode;
                var pathItems = source ? path.Source.FullName.Split(separator) : path.Destination.FullName.Split(separator);
                var lastItem = pathItems.Last();
                foreach (var item in pathItems)
                {
                    //not in the filter omit
                    if (!filter.HasFlag(path.DifferenceType))
                        continue;

                    var tmp = currentNode.Nodes.Cast<TreeNode>().Where(x => x.Text.Equals(item));
                    currentNode = tmp.Count() > 0 ? tmp.Single() : currentNode.Nodes.Add(string.Join("\\", pathItems), item);
                    if (lastItem.Equals(item))
                    {
                        if(path.DifferenceType.HasFlag( DiffType.ExistInSourceOnly | DiffType.ExistInDestinationOnly))
                            currentNode.ForeColor = Color.Red;
                        if (path.DifferenceType == DiffType.LastWritten)
                            currentNode.ForeColor = Color.Blue;
                    }
                }
            }
            return rootNode;
        }
 public HtmlTableRowGroup(DiffType diffType)
 {
     Class = diffType.ToString();
     DiffType = diffType;
     Lines = new List<HtmlTableLine>();
 }
Exemplo n.º 38
0
 private String GetDiffType(DiffType type)
 {
     switch (type)
     {
         case DiffType.None:
             return String.Empty;
         case DiffType.Element:
             return "1";
         case DiffType.Whitespace:
             return "2";
         case DiffType.Comment:
             return "3";
         case DiffType.PI:
             return "4";
         case DiffType.Text:
             return "5";
         case DiffType.Attribute:
             return "6";
         case DiffType.NS:
             return "7";
         case DiffType.Prefix:
             return "8";
         case DiffType.SourceExtra:
             return "9";
         case DiffType.TargetExtra:
             return "10";
         case DiffType.NodeType:
             return "11";
         case DiffType.CData:
             return "12";
         default:
             return String.Empty;
     }
 }
 public void Add(DiffType diffType)
 {
     if (diffType == DiffType.None)
     {
         if (DiffType != diffType)
             Current += "</pre><pre>";
     }
     else
     {
         Current += "</pre><pre class='" + diffType.ToString() + "'>";
     }
     DiffType = diffType;
 }
Exemplo n.º 40
0
 public FileDiff(string path, DiffType diffType)
 {
     this.Path = path;
     this.DiffType = diffType;
 }
Exemplo n.º 41
0
        // This function writes the result in XML format so that it can be used by other applications to display the diff
        private void WriteResult(XmlDiffNode sourceNode, XmlDiffNode targetNode, DiffType result)
        {
            _Writer.WriteStartElement(String.Empty, "Node", String.Empty);
            _Writer.WriteAttributeString(String.Empty, "SourceLineNum", String.Empty, (sourceNode != null) ? sourceNode.LineNumber.ToString() : "-1");
            _Writer.WriteAttributeString(String.Empty, "SourceLinePos", String.Empty, (sourceNode != null) ? sourceNode.LinePosition.ToString() : "-1");
            _Writer.WriteAttributeString(String.Empty, "TargetLineNum", String.Empty, (targetNode != null) ? targetNode.LineNumber.ToString() : "-1");
            _Writer.WriteAttributeString(String.Empty, "TargetLinePos", String.Empty, (targetNode != null) ? targetNode.LinePosition.ToString() : "-1");
            if (result == DiffType.Success)
            {
                _Writer.WriteStartElement(String.Empty, "Diff", String.Empty);
                _Writer.WriteEndElement();

                _Writer.WriteStartElement(String.Empty, "Lexical-equal", String.Empty);
                if (sourceNode.NodeType == XmlDiffNodeType.CData)
                {
                    _Writer.WriteString("<![CDATA[");
                    _Writer.WriteCData(GetNodeText(sourceNode, result));
                    _Writer.WriteString("]]>");
                }
                else
                {
                    _Writer.WriteCData(GetNodeText(sourceNode, result));
                }
                _Writer.WriteEndElement();
            }
            else
            {
                _Writer.WriteStartElement(String.Empty, "Diff", String.Empty);
                _Writer.WriteAttributeString(String.Empty, "DiffType", String.Empty, GetDiffType(result));

                if (sourceNode != null)
                {
                    _Writer.WriteStartElement(String.Empty, "File1", String.Empty);
                    if (sourceNode.NodeType == XmlDiffNodeType.CData)
                    {
                        _Writer.WriteString("<![CDATA[");
                        _Writer.WriteCData(GetNodeText(sourceNode, result));
                        _Writer.WriteString("]]>");
                    }
                    else
                    {

                        _Writer.WriteString(GetNodeText(sourceNode, result));
                    }
                    _Writer.WriteEndElement();
                }

                if (targetNode != null)
                {
                    _Writer.WriteStartElement(String.Empty, "File2", String.Empty);
                    if (targetNode.NodeType == XmlDiffNodeType.CData)
                    {
                        _Writer.WriteString("<![CDATA[");
                        _Writer.WriteCData(GetNodeText(targetNode, result));
                        _Writer.WriteString("]]>");
                    }
                    else
                    {
                        _Writer.WriteString(GetNodeText(targetNode, result));
                    }
                    _Writer.WriteEndElement();
                }

                _Writer.WriteEndElement();

                _Writer.WriteStartElement(String.Empty, "Lexical-equal", String.Empty);
                _Writer.WriteEndElement();
            }
            _Writer.WriteEndElement();
        }
Exemplo n.º 42
0
 // This is a helper function for WriteResult.  It gets the Xml representation of the different node we wants
 // to write out and all it's children.
 private String GetNodeText(XmlDiffNode diffNode, DiffType result)
 {
     string text = string.Empty;
     switch (diffNode.NodeType)
     {
         case XmlDiffNodeType.Element:
             if (result == DiffType.SourceExtra || result == DiffType.TargetExtra)
                 return diffNode.OuterXml;
             StringWriter str = new StringWriter();
             XmlWriter writer = XmlWriter.Create(str);
             XmlDiffElement diffElem = diffNode as XmlDiffElement;
             Debug.Assert(diffNode != null);
             writer.WriteStartElement(diffElem.Prefix, diffElem.LocalName, diffElem.NamespaceURI);
             XmlDiffAttribute diffAttr = diffElem.FirstAttribute;
             while (diffAttr != null)
             {
                 writer.WriteAttributeString(diffAttr.Prefix, diffAttr.LocalName, diffAttr.NamespaceURI, diffAttr.Value);
                 diffAttr = (XmlDiffAttribute)diffAttr.NextSibling;
             }
             if (diffElem is XmlDiffEmptyElement)
             {
                 writer.WriteEndElement();
                 text = str.ToString();
             }
             else
             {
                 text = str.ToString();
                 text += ">";
             }
             writer.Dispose();
             break;
         case XmlDiffNodeType.CData:
             text = ((XmlDiffCharacterData)diffNode).Value;
             break;
         default:
             text = diffNode.OuterXml;
             break;
     }
     return text;
 }
Exemplo n.º 43
0
 public Diff(DiffType kind, string targetFile)
 {
     Kind = kind;
     TargetFile = targetFile;
 }