本文整理汇总了C#中Microsoft.XmlDiffPatch.XmlDiff类的典型用法代码示例。如果您正苦于以下问题:C# XmlDiff类的具体用法?C# XmlDiff怎么用?C# XmlDiff使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XmlDiff类属于Microsoft.XmlDiffPatch命名空间,在下文中一共展示了XmlDiff类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: MinimalTreeDistanceAlgo
// Constructor
internal MinimalTreeDistanceAlgo( XmlDiff xmlDiff )
{
Debug.Assert( OperationCost.Length - 1 == (int)XmlDiffOperation.Undefined,
"Correct the OperationCost array so that it reflects the XmlDiffOperation enum." );
Debug.Assert( xmlDiff != null );
_xmlDiff = xmlDiff;
}
开发者ID:Podracer,项目名称:DAE-notepad,代码行数:9,代码来源:TreeMappingAlgorithm.cs
示例2: 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
示例3: Comparer
public Comparer(IDiffManager manager)
{
_results = new List<BaseDiffResultObject>();
_diff = new XmlDiff();
_diffOptions = new XmlDiffOptions();
_tempFilePath = Path.GetTempFileName();
Manager = manager;
}
开发者ID:silvestrova,项目名称:Custom-XML-Diff,代码行数:8,代码来源:Comparer.cs
示例4: 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> <font style='background-color: red'" +
"color='black'>removed</font> <font style='background-color: " +
"lightgreen' color='black'>changed</font> " +
"<font style='background-color: red' color='blue'>moved from</font>" +
" <font style='background-color: yellow' color='blue'>moved to" +
"</font> <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
示例5: DefaultDiffEngine
/// <summary>
/// Create a default XML difference engine using the <see cref="DefaultDiffOptions" />
/// </summary>
/// <returns></returns>
public static XmlDiff DefaultDiffEngine()
{
var xmlDiff = new XmlDiff
{
Options = DefaultDiffOptions(),
Algorithm = XmlDiffAlgorithm.Auto
};
return xmlDiff;
}
开发者ID:RustyF,项目名称:EnergyTrading-Core,代码行数:14,代码来源:XmlDiffFactory.cs
示例6: CoordinateSystemXmlReaderTest
public CoordinateSystemXmlReaderTest()
{
XmlDiffOptions ignoreMost = XmlDiffOptions.IgnoreChildOrder |
XmlDiffOptions.IgnoreComments |
XmlDiffOptions.IgnoreDtd |
XmlDiffOptions.IgnorePI |
XmlDiffOptions.IgnoreWhitespace |
XmlDiffOptions.IgnoreXmlDecl ;
_xmlDiff = new XmlDiff(ignoreMost);
}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:11,代码来源:CoordinateSystemXmlReaderTest.cs
示例7: XmlHash
// Constructor
internal XmlHash( XmlDiff xmlDiff )
{
// set flags
_bIgnoreChildOrder = xmlDiff.IgnoreChildOrder;
_bIgnoreComments = xmlDiff.IgnoreComments;
_bIgnorePI = xmlDiff.IgnorePI;
_bIgnoreWhitespace = xmlDiff.IgnoreWhitespace;
_bIgnoreNamespaces = xmlDiff.IgnoreNamespaces;
_bIgnorePrefixes = xmlDiff.IgnorePrefixes;
_bIgnoreXmlDecl = xmlDiff.IgnoreXmlDecl;
_bIgnoreDtd = xmlDiff.IgnoreDtd;
}
开发者ID:ViniciusConsultor,项目名称:sqlschematool,代码行数:14,代码来源:XmlHash.cs
示例8: 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
示例9: 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
示例10: 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
示例11: 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
示例12: 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
示例13: 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
示例14: 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
示例15: WriteTo
// Methods
internal override void WriteTo( XmlWriter xmlWriter, XmlDiff xmlDiff )
{
xmlWriter.WriteStartElement( XmlDiff.Prefix, "node", XmlDiff.NamespaceUri );
xmlWriter.WriteAttributeString( "match", _sourceNode.GetRelativeAddress() );
WriteChildrenTo( xmlWriter, xmlDiff );
xmlWriter.WriteEndElement();
}
开发者ID:ariflagiwale,项目名称:PSUpdateXml,代码行数:10,代码来源:DiffgramOperation.cs
示例16: Compare
/// <summary>
/// Invokes the XmlDiff Compare method. The strings attribute order and whitespace are ignored.
/// </summary>
/// <param name="diffs">The raw byte array of "diffgram" XML returned.</param>
/// <param name="same">True if the two xml strings are identical.</param>
/// <returns>Number of bytes read.</returns>
private int Compare(out byte [] diffs, out bool same)
{
Encoding enc = Encoding.UTF8; //.Unicode;
System.IO.Stream stream = new System.IO.MemoryStream();
XmlDiff xDiff = new XmlDiff(XmlDiffOptions.IgnoreWhitespace);
XmlWriter writer = new XmlTextWriter(stream, enc);
same = xDiff.Compare(m_baseReader, m_targetReader, writer);
stream.Position = 0;
diffs = new Byte[stream.Length];
int bytesRead = stream.Read(diffs,0,(int)stream.Length);
writer.Close(); // closes stream too.
m_Compared = true;
return bytesRead;
}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:20,代码来源:XmlStringDiff.cs
示例17: CompareXmls
virtual protected bool CompareXmls(String xml1, String xml2) {
XmlDiff xmldiff = new XmlDiff(XmlDiffOptions.None);
return xmldiff.Compare(xml1, xml2, false);
}
开发者ID:Niladri24dutta,项目名称:itextsharp,代码行数:4,代码来源:XmlDSigTest.cs
示例18: WriteTo
internal override void WriteTo( XmlWriter xmlWriter, XmlDiff xmlDiff )
{
_xmlDiff = xmlDiff;
WriteTo( xmlWriter );
}
开发者ID:ArsenShnurkov,项目名称:XmlCompare,代码行数:5,代码来源:Diffgram.cs
示例19: 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
示例20: Diffgram
// Constructor
internal Diffgram( XmlDiff xmlDiff )
: base(0)
{
_xmlDiff = xmlDiff;
}
开发者ID:ArsenShnurkov,项目名称:XmlCompare,代码行数:6,代码来源:Diffgram.cs
注:本文中的Microsoft.XmlDiffPatch.XmlDiff类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论