当前位置: 首页>>代码示例>>C#>>正文


C# XmlDiff.Compare方法代码示例

本文整理汇总了C#中Microsoft.XmlDiffPatch.XmlDiff.Compare方法的典型用法代码示例。如果您正苦于以下问题:C# XmlDiff.Compare方法的具体用法?C# XmlDiff.Compare怎么用?C# XmlDiff.Compare使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.XmlDiffPatch.XmlDiff的用法示例。


在下文中一共展示了XmlDiff.Compare方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestSerialization

        public void TestSerialization()
        {
            MSBuildCodeMetricsReport report = MSBuildCodeMetricsReport.Create().CreateSummary().Report.CreateDetails().Report;

            report.Summary.AddMetric("VisualStudioMetrics", _cyclomaticComplexity).CreateRanges().
                AddRange("> 10", 5).
                AddRange("<= 10 and > 5", 3).
                AddRange("<= 5", 1);

            report.Summary.AddMetric("VisualStudioMetrics", _linesOfCode).CreateRanges().
                AddRange("> 100", 5).
                AddRange("<= 100 and > 50", 3).
                AddRange("<= 50", 1);

            report.Details.AddMetric("VisualStudioMetrics", _cyclomaticComplexity).CreateMeasures().
                AddMeasure("Method1() : void", 100).
                AddMeasure("Method2() : void", 50);

            report.Details.AddMetric("VisualStudioMetrics", _linesOfCode).CreateMeasures().
                AddMeasure("Method1() : void", 1000).
                AddMeasure("Method2() : void", 500);

            Stream ms = report.SerializeToMemoryStream(true);
            XmlDiff diff = new XmlDiff();
            Assert.IsTrue(diff.Compare(_expectedReportStream, ms));
        }
开发者ID:ericlemes,项目名称:MSBuildCodeMetrics,代码行数:26,代码来源:SerializationTests.cs

示例2: Equal

        internal static void Equal(string file1, string file2)
        {
            var diffFile = @"diff.xml";
            XmlTextWriter tw = new XmlTextWriter(new StreamWriter(diffFile));
            tw.Formatting = Formatting.Indented;
            var diff = new XmlDiff();
            diff.Options = XmlDiffOptions.IgnoreWhitespace | XmlDiffOptions.IgnoreComments | XmlDiffOptions.IgnoreXmlDecl;
            var result = diff.Compare(file1, file2, false, tw);
            tw.Close();
            if (!result)
            {
                //Files were not equal, so construct XmlDiffView.
                XmlDiffView dv = new XmlDiffView();

                //Load the original file again and the diff file.
                XmlTextReader orig = new XmlTextReader(file1);
                XmlTextReader diffGram = new XmlTextReader(diffFile);
                dv.Load(orig, diffGram);
                string tempFile = "test.htm";

                StreamWriter sw1 = new StreamWriter(tempFile);
                //Wrapping
                sw1.Write("<html><body><table>");
                sw1.Write("<tr><td><b>");
                sw1.Write(file1);
                sw1.Write("</b></td><td><b>");
                sw1.Write(file2);
                sw1.Write("</b></td></tr>");

                //This gets the differences but just has the 
                //rows and columns of an HTML table
                dv.GetHtml(sw1);

                //Finish wrapping up the generated HTML and 
                //complete the file by putting legend in the end just like the 
                //online tool.

                sw1.Write("<tr><td><b>Legend:</b> <font style='background-color: yellow'" +
                " color='black'>added</font>&nbsp;&nbsp;<font style='background-color: red'" +
                "color='black'>removed</font>&nbsp;&nbsp;<font style='background-color: " +
                "lightgreen' color='black'>changed</font>&nbsp;&nbsp;" +
                "<font style='background-color: red' color='blue'>moved from</font>" +
                "&nbsp;&nbsp;<font style='background-color: yellow' color='blue'>moved to" +
                "</font>&nbsp;&nbsp;<font style='background-color: white' color='#AAAAAA'>" + "ignored</font></td></tr>");

                sw1.Write("</table></body></html>");

                //HouseKeeping...close everything we dont want to lock.
                sw1.Close();
                orig.Close();
                diffGram.Close();
                Process.Start("test.htm");
            }

            Assert.True(result);
        }
开发者ID:jexuswebserver,项目名称:Microsoft.Web.Administration,代码行数:56,代码来源:XmlAssert.cs

示例3: GenerateDiffGram

        public XElement GenerateDiffGram(XElement element1, XElement element2) {
            using (var node1Reader = element1.CreateReader())
            using (var node2Reader = element2.CreateReader()) {
                var result = new XDocument();
                using (var writer = result.CreateWriter()) {
                    var diff = new XmlDiff(XmlDiffOptions.IgnoreChildOrder | XmlDiffOptions.IgnoreWhitespace | XmlDiffOptions.IgnoreComments | XmlDiffOptions.IgnoreXmlDecl);
                    diff.Compare(node1Reader, node2Reader, writer);
                    writer.Flush();
                    writer.Close();
                }

                return result.Root;
            }
        }
开发者ID:Higea,项目名称:Orchard,代码行数:14,代码来源:DiffGramAnalyzer.cs

示例4: DiffXmlStrict

        public static void DiffXmlStrict(string actual, string expected)
        {
            XmlDocument expectedDoc;
            XmlDocument actualDoc;

            try
            {
                expectedDoc = new XmlDocument();
                expectedDoc.LoadXml(expected);
            }
            catch (XmlException e)
            {
                throw new Exception("Expected: " + e.Message + "\r\n" + expected);
            }

            try
            {
                actualDoc = new XmlDocument();
                actualDoc.LoadXml(actual);
            }
            catch (XmlException e)
            {
                throw new Exception("Actual: " + e.Message + "\r\n" + actual);
            }

            using (var stringWriter = new StringWriter())
            using (var writer = new XmlTextWriter(stringWriter))
            {
                writer.Formatting = Formatting.Indented;

                var xmldiff = new XmlDiff(XmlDiffOptions.None
                    //XmlDiffOptions.IgnoreChildOrder |
                    | XmlDiffOptions.IgnoreNamespaces
                    //XmlDiffOptions.IgnorePrefixes
                    );
                var identical = xmldiff.Compare(expectedDoc, actualDoc, writer);

                if (!identical)
                {
                    var error = string.Format("Expected:\r\n{0}\r\n\r\n" + "Actual:\r\n{1}\r\n\r\nDiff:\r\n{2}",
                        expected, actual, stringWriter.GetStringBuilder());

                    throw new Exception(error);
                }
            }
        }
开发者ID:razer21,项目名称:WebApiProblem,代码行数:46,代码来源:XmlDiff.cs

示例5: CompareJson

 public static bool CompareJson(string expected, string actual)
 {
     var expectedDoc = JsonConvert.DeserializeXmlNode(expected, "root");
     var actualDoc = JsonConvert.DeserializeXmlNode(actual, "root");
     var diff = new XmlDiff(XmlDiffOptions.IgnoreWhitespace |
                            XmlDiffOptions.IgnoreChildOrder);
     using (var ms = new MemoryStream())
     {
         var writer = new XmlTextWriter(ms, Encoding.UTF8);
         var result = diff.Compare(expectedDoc, actualDoc, writer);
         if (!result)
         {
             ms.Seek(0, SeekOrigin.Begin);
             Console.WriteLine(new StreamReader(ms).ReadToEnd());
         }
         return result;
     }
 }
开发者ID:boghbogh,项目名称:sandbox,代码行数:18,代码来源:CRUDTests.cs

示例6: Serializable

        public void Serializable()
        {
            XmlDiff diff = new XmlDiff();
            LayoutBox layoutBox = LayoutBox.LoadFromString(LayoutingResource.LayoutsDefault);
            String result = layoutBox.Serialize();

            diff.IgnoreChildOrder = true;
            diff.IgnoreComments = true;
            diff.IgnoreDtd = true;
            diff.IgnoreNamespaces = true;
            diff.IgnorePI = true;
            diff.IgnorePrefixes = true;
            diff.IgnoreWhitespace = true;
            diff.IgnoreXmlDecl = true;

            StringWriter diffgramString = new StringWriter();
            XmlTextWriter diffgramXml = new XmlTextWriter(diffgramString);
            bool diffBool = diff.Compare(new XmlTextReader(new StringReader(result)), new XmlTextReader(new StringReader(LayoutingResource.LayoutsDefault)), diffgramXml);
            //MessageBox.Show(diffgramString.ToString());
            Assert.True(diffBool);
        }
开发者ID:jonbws,项目名称:strengthreport,代码行数:21,代码来源:LayoutBoxTest.cs

示例7: Compare

        /// <summary>
        /// Compares the two XML files and throws an error if they are different.
        /// </summary>
        public static void Compare(XmlDocument expected, XmlDocument actual)
        {
            XmlNamespaceManager ns = new XmlNamespaceManager(expected.NameTable);
            ns.AddNamespace("tst", "http://schemas.asidua.com/testing");

            var diffReport = new StringBuilder();

            //  Remove the ignored nodes from both XML documents
            foreach (XmlAttribute ignored in expected.SelectNodes("//@tst:IGNORE[.='Content']", ns))
            {
                string xpath = generateXPath(ignored.OwnerElement);

                //  Remove the node's content from the expected results
                ignored.OwnerElement.InnerText = "";
                ignored.OwnerElement.RemoveAttribute(ignored.Name);

                //  Remove the node's content from the actual results
                var node = actual.SelectSingleNode(xpath);
                if (node != null) node.InnerText = "";
            }

            XmlDiff comparer = new XmlDiff();
            comparer.Options = XmlDiffOptions.IgnoreComments | XmlDiffOptions.IgnoreNamespaces | XmlDiffOptions.IgnorePrefixes | XmlDiffOptions.IgnoreWhitespace | XmlDiffOptions.IgnoreXmlDecl;

            var settings = new XmlWriterSettings
            {
                OmitXmlDeclaration = true,
                Indent = true,
            };
            using (var writer = XmlWriter.Create(diffReport, settings))
            {
                Assert.IsTrue(
                    comparer.Compare(expected, actual, writer),
                    "Expected Results:\n{0}\n\n" +
                    "Actual Results:\n{1}\n\n" +
                    "Difference Report:\n{2}",
                    formatXml(expected), formatXml(actual), diffReport
                );
            }
        }
开发者ID:AlanGibson-Asidua,项目名称:hello-adi-fuseesb,代码行数:43,代码来源:Utilities.cs

示例8: GenerateOutput

	public void GenerateOutput(BuildItem buildItem, Stream outputStream, IDictionary<string, Stream> inputFormatStreams, string defaultNamespace)
	{
		outputStream = new UncloseableStream(outputStream);
		Stream undeadOial = inputFormatStreams["UndeadOIAL"];
		Stream liveOial = inputFormatStreams["LiveOIAL"];

		XmlDiff xmlDiff = new XmlDiff(XmlDiffOptions.IgnoreComments | XmlDiffOptions.IgnoreXmlDecl | XmlDiffOptions.IgnorePrefixes);

		xmlDiff.Algorithm = XmlDiffAlgorithm.Precise;

		bool identical = false;

		MemoryStream diffgram = new MemoryStream(8192);

		using (XmlWriter diffgramWriter = XmlWriter.Create(diffgram))
		{
			try
			{
				using (XmlReader undeadReader = XmlReader.Create(undeadOial, XmlReaderSettings), liveReader = XmlReader.Create(liveOial, XmlReaderSettings))
				{
					identical = xmlDiff.Compare(undeadReader, liveReader, diffgramWriter);
				}
			}
			finally
			{
				undeadOial.Seek(0, SeekOrigin.Begin);
				liveOial.Seek(0, SeekOrigin.Begin);
			}
		}

		// Files have been compared, and the diff has been written to the diffgramwriter.

		TextWriter resultHtml = new StreamWriter(outputStream);
		resultHtml.WriteLine("<html><head>");
		resultHtml.WriteLine("<style TYPE='text/css' MEDIA='screen'>");
		resultHtml.Write("<!-- td { font-family: Courier New; font-size:14; } " +
							"th { font-family: Arial; } " +
							"p { font-family: Arial; } -->");
		resultHtml.WriteLine("</style></head>");
		resultHtml.WriteLine("<body><h3 style='font-family:Arial'>XmlDiff view</h3><table border='0'><tr><td><table border='0'>");
		resultHtml.WriteLine("<tr><th>Undead OIAL</th><th>Live OIAL</th></tr>" +
							"<tr><td colspan=2><hr size=1></td></tr>");

		if (identical)
		{
			resultHtml.WriteLine("<tr><td colspan='2' align='middle'>Files are identical.</td></tr>");
		}
		else
		{
			resultHtml.WriteLine("<tr><td colspan='2' align='middle'>Files are different.</td></tr>");
		}

		diffgram.Seek(0, SeekOrigin.Begin);
		XmlDiffView xmlDiffView = new XmlDiffView();

		XmlTextReader sourceReader = new XmlTextReader(undeadOial);

		sourceReader.XmlResolver = null;

		xmlDiffView.Load(sourceReader, new XmlTextReader(diffgram));

		xmlDiffView.GetHtml(resultHtml);

		resultHtml.WriteLine("</table></table></body></html>");

		resultHtml.Flush();
		resultHtml.Close();
	}
开发者ID:cjheath,项目名称:NORMA,代码行数:68,代码来源:OIALDiffCustomTool.cs

示例9: Main


//.........这里部分代码省略.........
            string legend = sourceXml.Substring( sourceXml.LastIndexOf("\\") + 1 ) + " & " +
                            targetXml.Substring( targetXml.LastIndexOf("\\") + 1 ) + " -> " +
                            diffgram.Substring( diffgram.LastIndexOf("\\") + 1 );
            if ( optionsString != string.Empty )
                legend += " (" + optionsString + ")";

            if ( legend.Length < 60 )
                legend += new String( ' ', 60 - legend.Length );
            else
                legend += "\n" + new String( ' ', 60 );

            System.Console.Write( legend );

            // create diffgram writer
            XmlWriter DiffgramWriter = new XmlTextWriter( diffgram, new System.Text.UnicodeEncoding() );

            // create XmlDiff object & set the options
            XmlDiff xmlDiff = new XmlDiff( options );
            xmlDiff.Algorithm = algorithm;

            // compare xml files
            bool bIdentical;
            if ( bNodes ) {
                if ( bFragment ) {
                    Console.Write( "Cannot have option 'd' and 'f' together." );
                    return;
                }

                XmlDocument sourceDoc = new XmlDocument();
                sourceDoc.Load( sourceXml );
                XmlDocument targetDoc = new XmlDocument();
                targetDoc.Load( targetXml );

                bIdentical = xmlDiff.Compare( sourceDoc, targetDoc, DiffgramWriter );
            }
            else {
                bIdentical = xmlDiff.Compare( sourceXml, targetXml, bFragment, DiffgramWriter );
            }

            /*
             *             if ( bMeasurePerf ) {
                Type type = xmlDiff.GetType();
                MemberInfo[] mi = type.GetMember( "_xmlDiffPerf" );
                if ( mi != null && mi.Length > 0 ) {
                    XmlDiffPerf xmldiffPerf = (XmlDiffPerf)type.InvokeMember( "_xmlDiffPerf", BindingFlags.GetField, null, xmlDiff, new object[0]);
                }
            }
            */

            // write result
            if ( bIdentical )
                System.Console.Write( "identical" );
            else
                System.Console.Write( "different" );

            DiffgramWriter.Close();

            // verify
            if ( !bIdentical && bVerify )
            {
                XmlNode sourceNode;
                if ( bFragment )
                {
                    NameTable nt = new NameTable();
                    XmlTextReader tr = new XmlTextReader( new FileStream( sourceXml, FileMode.Open, FileAccess.Read ),
                                                          XmlNodeType.Element,
开发者ID:ArsenShnurkov,项目名称:XmlCompare,代码行数:67,代码来源:TestXmlDiff.cs

示例10: CompareXml

        private static void CompareXml(string actualFileLocation, string expectedFileName)
        {
            Contract.Requires(!String.IsNullOrEmpty(actualFileLocation));
            Contract.Requires(!String.IsNullOrEmpty(expectedFileName));
            Contract.Requires(File.Exists(actualFileLocation));

            var actualFile = new XmlDocument();
            actualFile.Load(actualFileLocation);

            var expectedFile = new XmlDocument();
            expectedFile.Load(Assembly.GetExecutingAssembly().GetManifestResourceStream("Oddleif.RunKeeper.Client.Test.ExpectedOutput." + expectedFileName));

            var diff = new XmlDiff();

            Assert.IsTrue(diff.Compare(expectedFile.DocumentElement, actualFile.DocumentElement));
        }
开发者ID:Oddleif,项目名称:runkeeper-sdk-for-net,代码行数:16,代码来源:RunKeeperAccountTest.cs

示例11: DoCompare

        private void DoCompare(string changed)
        {
            CleanupTempFiles();

            XmlDocument original = this.model.Document;
            XmlDocument doc = new XmlDocument();

            XmlReaderSettings settings = model.GetReaderSettings();
            using (XmlReader reader = XmlReader.Create(changed, settings)) {
                doc.Load(reader);
            }

            string startupPath = Application.StartupPath;
            //output diff file.
            string diffFile = Path.Combine(Path.GetTempPath(),
                Path.GetFileNameWithoutExtension(Path.GetRandomFileName()) + ".xml");
            this.tempFiles.AddFile(diffFile, false);

            bool isEqual = false;
            XmlTextWriter diffWriter = new XmlTextWriter(diffFile, Encoding.UTF8);
            diffWriter.Formatting = Formatting.Indented;
            using (diffWriter) {
                XmlDiff diff = new XmlDiff();
                isEqual = diff.Compare(original, doc, diffWriter);
                diff.Options = XmlDiffOptions.None;
            }

            if (isEqual) {
                //This means the files were identical for given options.
                MessageBox.Show(this, SR.FilesAreIdenticalPrompt, SR.FilesAreIdenticalCaption,
                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            string tempFile = Path.Combine(Path.GetTempPath(),
                Path.GetFileNameWithoutExtension(Path.GetRandomFileName()) + ".htm");
            tempFiles.AddFile(tempFile, false);

            using (XmlReader diffGram = XmlReader.Create(diffFile, settings)) {
                XmlDiffView diffView = new XmlDiffView();
                diffView.Load(new XmlNodeReader(original), diffGram);
                using (TextWriter htmlWriter = new StreamWriter(tempFile)) {
                    SideBySideXmlNotepadHeader(this.model.FileName, changed, htmlWriter);
                    diffView.GetHtml(htmlWriter);
                }
            }

            /*
            Uri uri = new Uri(tempFile);
            WebBrowserForm browserForm = new WebBrowserForm(uri, "XmlDiff");
            browserForm.Show();
            */
        }
开发者ID:ic014308,项目名称:xml-notepad-for-mono,代码行数:53,代码来源:FormMain.cs

示例12: CompareColumns

        /// <summary>
        /// Compares table columns from two distinct XML schema files. These files are generated by the SerializeDB method.  
        /// This method is called from the CompareTables method.
        /// </summary>
        /// <param name="tableName">The string value representing the current SQL table object.</param>
        /// <param name="xnlSource">The XmlNodeList, a collection of source XML nodes to compare with the destination XML 
        /// nodes.</param>
        /// <param name="xnlDestination">The XmlNodeList, a collection of destination/target XML nodes to compare with the 
        /// source XML nodes.</param>
        /// <param name="xmlDiffDoc">The XML Diffgram object to update.</param>
        /// <param name="xmlDiff">The XmlDiff Object used from the GotDotNet XmlDiff class. Performs the XML node compare.</param>
        private static void CompareColumns(string tableName, XmlNodeList xnlSource, XmlNodeList xnlDestination,
            XmlDocument xmlDiffDoc, XmlDiff xmlDiff)
        {
            SQLObjects.ColumnCollection tableColumns = new SQLObjects.ColumnCollection(tableName);

            Hashtable htDropAdd = new Hashtable();
            // compare source columns to destination columns, looking for changed or missing destination columns
            if (xnlSource != null)
            {
                // if a matching destination table was found with columns
                if (xnlDestination != null)
                {
                    tableColumns.SchemaAction = SQLObjects.COLUMN.ColumnAction.Alter;
                    // identify the source columns that are different
                    foreach (XmlNode xn in xnlSource)
                    {
                        string column_Name = xn.ChildNodes[1].InnerXml;
                        XmlNode Found = FindNode(xnlDestination, column_Name, "<Column_Name>{0}</Column_Name>");
                        // look for existing columns
                        if (Found != null)
                        {
                            // if the columns don't compare then
                            if (!xmlDiff.Compare(xn, Found))
                            {
                                SQLObjects.COLUMN col = new SQLObjects.COLUMN();
                                col.Action = SQLObjects.COLUMN.ColumnAction.Alter;

                                // add original_rules from the destination column so that if they are not on the source columns we can exec sp_unbindrule on them.
                                // There is XSLT code to handle sp_bindrule for the source columns where they were not bound to the destination(original) column.
                                // IF the source and destination rule names are the same, then we should be able to ignore changing the column bound rule
                                XmlNode xnRule = xn.OwnerDocument.CreateNode(XmlNodeType.Element, "RULE_ORIG_NAME", xn.OwnerDocument.NamespaceURI);
                                if (Found.SelectSingleNode("Rule_Name") != null)
                                {
                                    xnRule.InnerXml = Found.SelectSingleNode("Rule_Name").InnerXml;
                                    xn.AppendChild(xnRule);
                                }

                                xnRule = xn.OwnerDocument.CreateNode(XmlNodeType.Element, "RULE_ORIG_OWNER", xn.OwnerDocument.NamespaceURI);
                                if (Found.SelectSingleNode("Rule_Owner") != null)
                                {
                                    xnRule.InnerXml = Found.SelectSingleNode("Rule_Owner").InnerXml;
                                    xn.AppendChild(xnRule);
                                }

                                XmlNode xnDefault = xn.OwnerDocument.CreateNode(XmlNodeType.Element, "DEFAULT_ORIG_NAME", xn.OwnerDocument.NamespaceURI);
                                if (Found.SelectSingleNode("Default_Name") != null)
                                {
                                    xnDefault.InnerXml = Found.SelectSingleNode("Default_Name").InnerXml;
                                    xn.AppendChild(xnDefault);
                                }

                                xnDefault = xn.OwnerDocument.CreateNode(XmlNodeType.Element, "DEFAULT_ORIG_VALUE", xn.OwnerDocument.NamespaceURI);
                                if (Found.SelectSingleNode("Default_Value") != null)
                                {
                                    xnDefault.InnerXml = Found.SelectSingleNode("Default_Value").InnerXml;
                                    xn.AppendChild(xnDefault);
                                }

                                XmlNode xnRowGuidCol = xn.OwnerDocument.CreateNode(XmlNodeType.Element, "ORIG_RowGuidCol", xn.OwnerDocument.NamespaceURI);
                                if (Found.SelectSingleNode("isRowGuidCol") != null)
                                {
                                    xnRowGuidCol.InnerXml = Found.SelectSingleNode("isRowGuidCol").InnerXml;
                                    xn.AppendChild(xnRowGuidCol);
                                }

                                // lookup any altered columns to see if there are Reference dependencies
                                // may need to use something like this: descendant::*[contains(local-name(),'cKeyCol')]
                                for (int x = 1; x < 17; x++)
                                {
                                    if (Found.SelectSingleNode("../TABLE_REFERENCE/cRefCol" + x.ToString()) != null)
                                    {
                                        CheckColumnDependencies(column_Name, tableName, "DropAdd_References", "TABLE_REFERENCE", "Constraint", "cRefCol" + x.ToString(),
                                            false, ref htDropAdd, Found, xn, xmlDiffDoc);
                                    }
                                }

                                // lookup any altered columns to see if there are Constraint dependencies
                                CheckColumnDependencies(column_Name, tableName, "DropAdd_Constraints", "TABLE_CONSTRAINTS", "CONSTRAINT_NAME", "COLUMN_NAME",
                                    false, ref htDropAdd, Found, xn, xmlDiffDoc);

                                // lookup any altered columns to see if there are index dependencies
                                CheckColumnDependencies(column_Name, tableName, "DropAdd_Indexes", "TABLE_INDEX", "index_name", "index_keys",
                                    false, ref htDropAdd, Found, xn, xmlDiffDoc);

                                // add xml node to the table columns collection
                                SQLObjects.COLUMN c = col.Convert(xn);
                                tableColumns.Add(c);
                            }
                            else
//.........这里部分代码省略.........
开发者ID:ViniciusConsultor,项目名称:sqlschematool,代码行数:101,代码来源:SQLSchemaTool.cs

示例13: GenerateDiffGram

        /// <summary>
        /// Compare the xml data files
        /// </summary>
        /// <param name="sourceXmlFile">baseline file</param>
        /// <param name="changedXmlFile">actual file</param>
        /// <param name="fragment">xml data fragment</param>
        /// <param name="options">comparison options</param>
        /// <returns>data is identical</returns>
        private bool GenerateDiffGram(
            string sourceXmlFile,
            string changedXmlFile,
            bool fragment,
            XmlDiffOptions options)
        {
            // set class scope variables
            // MemoryStream diffgram
            bool identicalData;
            this.diffgram = new MemoryStream();
            XmlTextWriter diffgramWriter = new XmlTextWriter(
                new StreamWriter(this.diffgram));

            Trace.WriteLine("Comparing " + sourceXmlFile +
                " & " + changedXmlFile);
            XmlDiffOptions xmlDiffOptions = (XmlDiffOptions)options;
            XmlDiff xmlDiff = new XmlDiff(xmlDiffOptions);

            try
            {
                identicalData = xmlDiff.Compare(
                    sourceXmlFile,
                    changedXmlFile,
                    fragment,
                    diffgramWriter);
            }
            catch (XmlException format)
            {
                Trace.WriteLine(format.Message);
                throw;
            }
            Trace.WriteLine("Files compared " +
                (identicalData ? "identical." : "different."));

            return identicalData;
        }
开发者ID:ic014308,项目名称:xml-notepad-for-mono,代码行数:44,代码来源:XmlDiffView.cs

示例14: CompareXML

        internal static bool CompareXML(XDocument xmlDocument1, XDocument xmlDocument2)
        {
            XmlDiff diff = new XmlDiff();
            diff.IgnoreChildOrder = true;
            diff.IgnoreXmlDecl = true;
            diff.IgnoreWhitespace = true;
            diff.IgnoreComments = true;
            diff.IgnorePI = true;
            diff.IgnoreDtd = true;
            var doc1 = new XmlDocument();
            doc1.LoadXml(xmlDocument1.ToString());
            var doc2 = new XmlDocument();
            doc2.LoadXml(xmlDocument2.ToString());

            bool result = diff.Compare(doc1, doc2);

            return result;
        }
开发者ID:dur41d,项目名称:sdmxdotnet,代码行数:18,代码来源:Utility.cs

示例15: XmlDiffHtm

        public bool XmlDiffHtm(string source, string target, string intervalo, string server, string classe)
        {
            // Randomiza para criar arquivos unicos de comparação
            r = new Random();
            bool isEqual = false;

            //Pega o usuário logado...
            MembershipUser currentUser = Membership.GetUser();

            //output diff file.
            startupPath = ConfigurationManager.AppSettings["XMLData"] + "\\RPTs";
            diffFile = startupPath + Path.DirectorySeparatorChar + "vxd" + r.Next() + ".out";
            //
            XmlTextWriter tw = new XmlTextWriter(new StreamWriter(diffFile));
            tw.Formatting = Formatting.Indented;

            try
            {
                XmlReader expected = XmlReader.Create(new StringReader(target));
                XmlReader actual = XmlReader.Create(new StringReader(source));

                XmlDiff diff = new XmlDiff( XmlDiffOptions.IgnoreChildOrder |
                                            XmlDiffOptions.IgnoreComments   |
                                            XmlDiffOptions.IgnoreXmlDecl    |
                                            XmlDiffOptions.IgnoreWhitespace);

                isEqual = diff.Compare(actual, expected, tw);
                tw.Close();

                //-----------------------------------------------------------------
                // Cria a comparação dos XMLs...
                XmlDiffView dv = new XmlDiffView();

                // Carrega o arquivo orig = source + o arquivo XML das Diff...
                XmlTextReader orig = new XmlTextReader(new StringReader(source)); //source
                XmlTextReader diffGram = new XmlTextReader(diffFile);
                dv.Load(orig,
                    diffGram);

                orig.Close();
                diffGram.Close();

                // Chama a função para gravar e formatar o conteudo + diff em HTM...
                if (!isEqual)
                { GrHtm(dv, intervalo, server, classe); }
                //
                return isEqual;
            }
            catch (XmlException xe)
            {
                divMessage.InnerHtml = "<span id='msg' style='color:#FF3300;font-size:Smaller;font-weight:bold;'>Ocorreu um erro de Comparação - " + xe.StackTrace + "</span>";
                return isEqual;
            }
        }
开发者ID:marcos-soares-bnu,项目名称:AMS,代码行数:54,代码来源:RptGeral.aspx.cs


注:本文中的Microsoft.XmlDiffPatch.XmlDiff.Compare方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。