本文整理汇总了C#中Chorus.merge.xml.generic.XmlMerger.Merge方法的典型用法代码示例。如果您正苦于以下问题:C# XmlMerger.Merge方法的具体用法?C# XmlMerger.Merge怎么用?C# XmlMerger.Merge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chorus.merge.xml.generic.XmlMerger
的用法示例。
在下文中一共展示了XmlMerger.Merge方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoMerge
internal static void DoMerge(MergeOrder mergeOrder, XmlMerger merger)
{
XmlNode ours;
XmlNode theirs;
XmlNode common;
DoPreMerge(mergeOrder, out ours, out theirs, out common);
var results = merger.Merge(ours, theirs, common);
DoPostMerge(mergeOrder.pathToOurs, results.MergedNode);
}
示例2: DoMerge
internal static void DoMerge(MergeOrder mergeOrder, XmlMerger merger)
{
XmlNode ours;
XmlNode theirs;
XmlNode common;
DoPreMerge(mergeOrder, out ours, out theirs, out common);
// The document element is being returned here, so our parent isn't relevant and won't be used by the merge
var results = merger.Merge(null, ours, theirs, common);
DoPostMerge(mergeOrder.pathToOurs, results.MergedNode);
}
示例3: CheckOneWay
private ChangeAndConflictAccumulator CheckOneWay(string ours, string theirs, string ancestor, params string[] xpaths)
{
XmlMerger m = new XmlMerger(new NullMergeSituation());
m.MergeStrategies.ElementStrategies.Add("a", ElementStrategy.CreateForKeyedElementInList("key"));
m.MergeStrategies.ElementStrategies.Add("b", ElementStrategy.CreateForKeyedElementInList("key"));
m.MergeStrategies.ElementStrategies.Add("c", ElementStrategy.CreateForKeyedElementInList("key"));
m.MergeStrategies.ElementStrategies.Add("d", ElementStrategy.CreateForKeyedElementInList("key"));
var result = m.Merge(ours, theirs, ancestor);
foreach (string xpath in xpaths)
{
XmlTestHelper.AssertXPathMatchesExactlyOne(result.MergedNode, xpath);
}
return result;
}
示例4: MergeChildren_UsesNodeToGenerateContextDescriptorIfPossible
public void MergeChildren_UsesNodeToGenerateContextDescriptorIfPossible()
{
string ancestor = @"<a>
<b key='one'>
<c key='a'>first</c>
</b>
</a>";
string red = ancestor;
string blue = @"<a>
<b key='one'>
<c key='a'>first</c>
<c key='b'>second</c>
</b>
</a>";
XmlMerger m = new XmlMerger(new NullMergeSituation());
m.MergeStrategies.ElementStrategies.Add("a", ElementStrategy.CreateForKeyedElementInList("key"));
var strategy = ElementStrategy.CreateForKeyedElementInList("key");
var contextGenerator = new MockContextGenerator();
strategy.ContextDescriptorGenerator = contextGenerator;
m.MergeStrategies.ElementStrategies.Add("b", strategy);
m.MergeStrategies.ElementStrategies.Add("c", ElementStrategy.CreateForKeyedElementInList("key"));
m.MergeStrategies.ElementStrategies.Add("d", ElementStrategy.CreateForKeyedElementInList("key"));
m.Merge(red, blue, ancestor);
Assert.That(contextGenerator.InputNode, Is.Not.Null);
Assert.That(contextGenerator.InputNode.Name, Is.EqualTo("b"));
}
示例5: CheckOneWay
private ChangeAndConflictAccumulator CheckOneWay(string ours, string theirs, string ancestor, MergeSituation situation,
Dictionary<string, ElementStrategy> specialMergeStrategies,
Action<string, ElementStrategy> adjustStrategy,
params string[] xpaths)
{
var m = new XmlMerger(situation);
AddMergeStrategies(m);
if (specialMergeStrategies != null)
{
foreach (var kvp in specialMergeStrategies)
m.MergeStrategies.ElementStrategies[kvp.Key] = kvp.Value; // don't use add, some may replace standard ones.
}
if (adjustStrategy != null)
{
foreach (var kvp in m.MergeStrategies.ElementStrategies)
adjustStrategy(kvp.Key, kvp.Value);
}
var result = m.Merge(ours, theirs, ancestor);
foreach (string xpath in xpaths)
{
XmlTestHelper.AssertXPathMatchesExactlyOne(result.MergedNode, xpath);
}
return result;
}
示例6: TextElement_WeEditedTheyDeleted_OursKept_ConflictRegistered
public void TextElement_WeEditedTheyDeleted_OursKept_ConflictRegistered()
{
string ancestor = @"<t>original</t>";
string ours = @"<t>mine</t>";
string theirs = @"<t></t>";
XmlMerger m = new XmlMerger(new NullMergeSituation());
var result = m.Merge(ours, theirs, ancestor);
XmlTestHelper.AssertXPathMatchesExactlyOne(result.MergedNode, "t[text()='mine']");
Assert.AreEqual(typeof(XmlTextEditVsRemovedConflict), result.Conflicts[0].GetType());
}
示例7: TextElement_EachEdited_OursKept_ConflictRegistered
public void TextElement_EachEdited_OursKept_ConflictRegistered()
{
string ancestor = @"<t>original</t>";
string ours = @"<t>mine</t>";
string theirs = @"<t>theirs</t>";
XmlMerger m = new XmlMerger(new MergeSituation("pretendPath", "userX", "XRev","userY", "YRev", MergeOrder.ConflictHandlingModeChoices.WeWin));
var result = m.Merge(ours, theirs, ancestor);
XmlTestHelper.AssertXPathMatchesExactlyOne(result.MergedNode, "t[text()='mine']");
Assert.AreEqual("pretendPath", result.Conflicts[0].RelativeFilePath);
Assert.AreEqual(typeof(XmlTextBothEditedTextConflict), result.Conflicts[0].GetType());
}
示例8: DoMerge
public static string DoMerge(
MergeStrategies mergeStrategies,
MergeSituation mergeSituation,
string ancestorXml, string ourXml, string theirXml,
IEnumerable<string> xpathQueriesThatMatchExactlyOneNode, IEnumerable<string> xpathQueriesThatReturnNull,
int expectedConflictCount, List<Type> expectedConflictTypes,
int expectedChangesCount, List<Type> expectedChangeTypes)
{
var doc = new XmlDocument();
var ourNode = XmlUtilities.GetDocumentNodeFromRawXml(ourXml, doc);
var theirNode = XmlUtilities.GetDocumentNodeFromRawXml(theirXml, doc);
var ancestorNode = XmlUtilities.GetDocumentNodeFromRawXml(ancestorXml, doc);
var eventListener = new ListenerForUnitTests();
var merger = new XmlMerger(mergeSituation)
{
MergeStrategies = mergeStrategies
};
var retval = merger.Merge(eventListener, ourNode, theirNode, ancestorNode).OuterXml;
Assert.AreSame(eventListener, merger.EventListener); // Make sure it never changes it, while we aren't looking, since at least one Merge method does that very thing.
CheckMergeResults(retval, eventListener,
xpathQueriesThatMatchExactlyOneNode, xpathQueriesThatReturnNull,
expectedConflictCount, expectedConflictTypes,
expectedChangesCount, expectedChangeTypes);
return retval;
}