本文整理汇总了C#中Chorus.merge.xml.generic.XmlMerger类的典型用法代码示例。如果您正苦于以下问题:C# XmlMerger类的具体用法?C# XmlMerger怎么用?C# XmlMerger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XmlMerger类属于Chorus.merge.xml.generic命名空间,在下文中一共展示了XmlMerger类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:StephenMcConnel,项目名称:flexbridge,代码行数:9,代码来源:CustomLayoutMergeService.cs
示例2: CreateXmlMergerForFieldWorksData
internal static XmlMerger CreateXmlMergerForFieldWorksData(MergeOrder mergeOrder, MetadataCache mdc)
{
var merger = new XmlMerger(mergeOrder.MergeSituation)
{
EventListener = mergeOrder.EventListener
};
BootstrapSystem(mdc, merger);
return merger;
}
开发者ID:StephenMcConnel,项目名称:flexbridge,代码行数:9,代码来源:FieldWorksMergeServices.cs
示例3: FixtureSetup
public void FixtureSetup()
{
_mdc = MetadataCache.TestOnlyNewCache;
var mergeOrder = new MergeOrder(null, null, null, new NullMergeSituation())
{
EventListener = new ListenerForUnitTests()
};
_merger = FieldWorksMergeServices.CreateXmlMergerForFieldWorksData(mergeOrder, _mdc);
}
开发者ID:gmartin7,项目名称:flexbridge,代码行数:9,代码来源:TimeDataTypeReportTests.cs
示例4: ChorusNotesAnnotationMergingStrategy
/// <summary>
/// Produce a string that represents the 3-way merger of the given three elements.
/// </summary>
public ChorusNotesAnnotationMergingStrategy(MergeOrder order)
{
_annotationMerger = new XmlMerger(order.MergeSituation)
{
EventListener = order.EventListener
};
SetupElementStrategies();
}
开发者ID:sillsdev,项目名称:chack,代码行数:12,代码来源:ChorusNotesAnnotationMergingStrategy.cs
示例5: Do3WayMerge
public void Do3WayMerge(MetadataCache mdc, MergeOrder mergeOrder)
{
var merger = new XmlMerger(mergeOrder.MergeSituation)
{
EventListener = mergeOrder.EventListener
};
CustomLayoutMergeStrategiesMethod.AddElementStrategies(merger.MergeStrategies);
CustomLayoutMergeService.DoMerge(mergeOrder, merger);
}
开发者ID:gmartin7,项目名称:flexbridge,代码行数:9,代码来源:FieldWorksConfigurationLayoutTypeHandlerStrategy.cs
示例6: LiftEntryMergingStrategy
/// <summary>
/// Produce a string that represents the 3-way merger of the given three elements.
/// </summary>
public LiftEntryMergingStrategy(MergeOrder mergeOrder)
{
_entryMerger = new XmlMerger(mergeOrder.MergeSituation)
{
MergeStrategies = {ElementToMergeStrategyKeyMapper = new LiftElementToMergeStrategyKeyMapper()},
EventListener = mergeOrder.EventListener
};
LiftElementStrategiesMethod.AddLiftElementStrategies(_entryMerger.MergeStrategies);
}
开发者ID:sillsdev,项目名称:chack,代码行数:13,代码来源:LiftEntryMergingStrategy.cs
示例7: 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);
}
开发者ID:gmartin7,项目名称:flexbridge,代码行数:10,代码来源:CustomLayoutMergeService.cs
示例8: TestSetup
public override void TestSetup()
{
base.TestSetup();
Mdc.UpgradeToVersion(MetadataCache.MaximumModelVersion);
var mergeOrder = new MergeOrder(null, null, null, new NullMergeSituation())
{
EventListener = new ListenerForUnitTests()
};
_merger = FieldWorksMergeServices.CreateXmlMergerForFieldWorksData(mergeOrder, Mdc);
}
开发者ID:gmartin7,项目名称:flexbridge,代码行数:10,代码来源:ReferenceAtomicDataTypeReportTests.cs
示例9: LiftRangesMergingStrategy
/// <summary>
/// Constructor
/// </summary>
public LiftRangesMergingStrategy(MergeOrder mergeOrder)
{
_merger = new XmlMerger(mergeOrder.MergeSituation)
{
EventListener = mergeOrder.EventListener
};
LiftBasicElementStrategiesMethod.AddLiftBasicElementStrategies(_merger.MergeStrategies);
LiftRangesElementStrategiesMethod.AddLiftRangeElementStrategies(_merger.MergeStrategies);
}
开发者ID:JessieGriffin,项目名称:chorus,代码行数:13,代码来源:LiftRangesMergingStrategy.cs
示例10: GetStrategies
/// <summary>
/// Gets the collection of element merge strategies.
/// </summary>
public MergeStrategies GetStrategies()
{
var merger = new XmlMerger(new MergeSituation(null, null, null, null, null, MergeOrder.ConflictHandlingModeChoices.WeWin));
var def = new ElementStrategy(true)
{
MergePartnerFinder = new FindByEqualityOfTree()
};
merger.MergeStrategies.SetStrategy("def", def);
return merger.MergeStrategies;
}
开发者ID:sillsdev,项目名称:chack,代码行数:13,代码来源:DropTheirsMergeStrategy.cs
示例11: ChildOrderer
internal ChildOrderer(List<XmlNode> primary, List<XmlNode> others, Dictionary<XmlNode, XmlNode> correspondences,
XmlMerger merger, ChildOrder parentOrder)
{
_primary = primary;
_others = others;
_correspondences = correspondences;
_positions = new PositionRecord[others.Count];
Debug.Assert(merger != null);
_merger = merger;
_parentOrder = parentOrder;
}
开发者ID:regnrand,项目名称:chorus,代码行数:11,代码来源:MergeChildrenMethod.cs
示例12: AllHadProperty_ButNothingElse
public void AllHadProperty_ButNothingElse()
{
const string commonAncestor =
@"<Lexicon>
<LexEntry guid='c1ed94c5-e382-11de-8a39-0800200c9a66'>
<Etymology>
</Etymology>
</LexEntry>
</Lexicon>";
const string ours =
@"<Lexicon>
<LexEntry guid='c1ed94c5-e382-11de-8a39-0800200c9a66'>
<Etymology>
</Etymology>
</LexEntry>
</Lexicon>";
const string theirs =
@"<Lexicon>
<LexEntry guid='c1ed94c5-e382-11de-8a39-0800200c9a66'>
<Etymology>
</Etymology>
</LexEntry>
</Lexicon>";
var listener = new ListenerForUnitTests();
var merger = new XmlMerger(new NullMergeSituation())
{
EventListener = listener
};
merger.MergeStrategies.SetStrategy("Lexicon", ElementStrategy.CreateSingletonElement());
var strat = ElementStrategy.CreateForKeyedElement("guid", false);
strat.AttributesToIgnoreForMerging.Add("guid");
merger.MergeStrategies.SetStrategy("LexEntry", strat);
strat = ElementStrategy.CreateSingletonElement();
strat.NumberOfChildren = NumberOfChildrenAllowed.ZeroOrOne;
merger.MergeStrategies.SetStrategy("Etymology", strat);
strat = ElementStrategy.CreateForKeyedElement("guid", false);
strat.AttributesToIgnoreForMerging.Add("guid");
merger.MergeStrategies.SetStrategy("LexEtymology", strat);
XmlTestHelper.DoMerge(merger.MergeStrategies, merger.MergeSituation,
commonAncestor, ours, theirs,
new[] { "Lexicon/LexEntry/Etymology" },
null,
0, new List<Type>(),
0, new List<Type>());
}
开发者ID:JessieGriffin,项目名称:chorus,代码行数:52,代码来源:MergeLimitedChildrenServiceTests.cs
示例13: AddConflictToListener
/// <summary>
/// Add conflict. If RecordContextInConflict fails to set a context, and nodeToFindGeneratorFrom is non-null,
/// attempt to add a context based on the argument.
/// </summary>
public static void AddConflictToListener(IMergeEventListener listener, IConflict conflict, XmlNode oursContext,
XmlNode theirsContext, XmlNode ancestorContext,
IGenerateHtmlContext htmlContextGenerator, XmlMerger merger, XmlNode nodeToFindGeneratorFrom)
{
// NB: All these steps are crucially ordered.
listener.RecordContextInConflict(conflict);
if ((conflict.Context == null || conflict.Context is NullContextDescriptor) && nodeToFindGeneratorFrom != null)
{
// We are too far up the stack for the listener to have been told a context.
// Make one out of the current node.
conflict.Context = merger.GetContext(nodeToFindGeneratorFrom);
}
conflict.MakeHtmlDetails(oursContext, theirsContext, ancestorContext, htmlContextGenerator);
listener.ConflictOccurred(conflict);
}
开发者ID:regnrand,项目名称:chorus,代码行数:19,代码来源:XmlMergeService.cs
示例14: MergeTextNodesMethod
/// <summary>
/// This is for regular three-way merges.
/// </summary>
public MergeTextNodesMethod(XmlMerger merger, IElementDescriber elementDescriber,
HashSet<XmlNode> skipInnerMergeFor,
ref XmlNode ours, List<XmlNode> ourKeepers,
XmlNode theirs, List<XmlNode> theirKeepers,
XmlNode ancestor, List<XmlNode> ancestorKeepers)
{
_ours = ours;
_ourKeepers = ourKeepers;
_theirs = theirs;
_theirKeepers = theirKeepers;
_ancestor = ancestor;
_ancestorKeepers = ancestorKeepers;
_merger = merger;
_elementDescriber = elementDescriber;
_skipInnerMergeFor = skipInnerMergeFor;
}
开发者ID:sillsdev,项目名称:chack,代码行数:19,代码来源:MergeTextNodesMethod.cs
示例15: BootstrapSystem
/// <summary>
/// Bootstrap a merger for the new-styled (nested) files.
/// </summary>
/// <remarks>
/// 1. A generic 'header' element will be handled, although it may not appear in the file.
/// 2. All classes will be included.
/// 3. Merge strategies for class properties (regular or custom) will have keys of "classname+propname" to make them unique, system-wide.
/// </remarks>
private static void BootstrapSystem(MetadataCache metadataCache, XmlMerger merger)
{
merger.MergeStrategies.ElementToMergeStrategyKeyMapper = new FieldWorksElementToMergeStrategyKeyMapper();
var sharedElementStrategies = new Dictionary<string, ElementStrategy>();
CreateSharedElementStrategies(sharedElementStrategies);
var strategiesForMerger = merger.MergeStrategies;
ContextGen.MergeStrategies = strategiesForMerger;
foreach (var sharedKvp in sharedElementStrategies)
strategiesForMerger.SetStrategy(sharedKvp.Key, sharedKvp.Value);
var customPropDefnStrat = new ElementStrategy(false)
{
MergePartnerFinder = new FindByMultipleKeyAttributes(new List<string> { SharedConstants.Name, SharedConstants.Class }),
ContextDescriptorGenerator = new FieldWorksCustomPropertyContextGenerator(),
IsAtomic = true,
NumberOfChildren = NumberOfChildrenAllowed.Zero
};
strategiesForMerger.SetStrategy(SharedConstants.CustomField, customPropDefnStrat);
var headerStrategy = CreateSingletonElementType(false);
headerStrategy.ContextDescriptorGenerator = ContextGen;
strategiesForMerger.SetStrategy(SharedConstants.Header, headerStrategy);
// There are two abstract class names used: CmAnnotation and DsChart.
// Chorus knows how to find the matching element for these, as they use <CmAnnotation class='concreteClassname'.
// So, add a keyed strategy for each of them.
var keyedStrat = ElementStrategy.CreateForKeyedElement(SharedConstants.GuidStr, false);
keyedStrat.AttributesToIgnoreForMerging.Add(SharedConstants.Class);
keyedStrat.AttributesToIgnoreForMerging.Add(SharedConstants.GuidStr);
strategiesForMerger.SetStrategy(SharedConstants.CmAnnotation, keyedStrat);
keyedStrat = ElementStrategy.CreateForKeyedElement(SharedConstants.GuidStr, false);
keyedStrat.AttributesToIgnoreForMerging.Add(SharedConstants.Class);
keyedStrat.AttributesToIgnoreForMerging.Add(SharedConstants.GuidStr);
strategiesForMerger.SetStrategy(SharedConstants.DsChart, keyedStrat);
foreach (var classInfo in metadataCache.AllConcreteClasses)
{
MakeClassStrategy(strategiesForMerger, classInfo, ContextGen);
AddPropertyStrategiesForClass(strategiesForMerger, classInfo);
}
}
开发者ID:gmartin7,项目名称:flexbridge,代码行数:53,代码来源:FieldWorksMergeServices.cs
示例16: DuplicateWritingSystemsElementsAreRemoved
public void DuplicateWritingSystemsElementsAreRemoved()
{
const string badData =
@"<ProjectLexiconSettings>
<WritingSystems addToSldr='true' />
<WritingSystems addToSldr='true' goner='true' />
</ProjectLexiconSettings>";
var doc = new XmlDocument();
var badRootNode = XmlUtilities.GetDocumentNodeFromRawXml(badData, doc);
var merger = new XmlMerger(new NullMergeSituation());
merger.EventListener = new ListenerForUnitTests();
ProjectLexiconSettingsFileHandler.SetupElementStrategies(merger);
var oldValue = XmlMergeService.RemoveAmbiguousChildNodes;
XmlMergeService.RemoveAmbiguousChildNodes = true;
XmlMergeService.RemoveAmbiguousChildren(merger.EventListener, merger.MergeStrategies, badRootNode);
XmlMergeService.RemoveAmbiguousChildNodes = oldValue;
var childNodes = badRootNode.SelectNodes("WritingSystems");
Assert.IsNotNull(childNodes);
Assert.IsTrue(childNodes.Count == 1);
Assert.IsNull(childNodes[0].Attributes["goner"]);
}
开发者ID:regnrand,项目名称:chorus,代码行数:21,代码来源:ProjectLexiconSettingsFileMergeTests.cs
示例17: DuplicateSpecialElementsAreRemoved
public void DuplicateSpecialElementsAreRemoved()
{
const string badData =
@"<ldml>
<special xmlns:palaso='urn://palaso.org/ldmlExtensions/v1' />
<special xmlns:palaso='urn://palaso.org/ldmlExtensions/v1' goner='true' />
<special xmlns:palaso2='urn://palaso.org/ldmlExtensions/v2' />
<special xmlns:palaso2='urn://palaso.org/ldmlExtensions/v2' goner='true' />
<special xmlns:fw='urn://fieldworks.sil.org/ldmlExtensions/v1' />
<special xmlns:fw='urn://fieldworks.sil.org/ldmlExtensions/v1' goner='true' />
</ldml>";
var doc = new XmlDocument();
var badRootNode = XmlUtilities.GetDocumentNodeFromRawXml(badData, doc);
var merger = new XmlMerger(new NullMergeSituation());
merger.EventListener = new ListenerForUnitTests();
LdmlFileHandler.SetupElementStrategies(merger);
var oldValue = XmlMergeService.RemoveAmbiguousChildNodes;
XmlMergeService.RemoveAmbiguousChildNodes = true;
XmlMergeService.RemoveAmbiguousChildren(merger.EventListener, merger.MergeStrategies, badRootNode);
XmlMergeService.RemoveAmbiguousChildNodes = oldValue;
var childNodes = badRootNode.SelectNodes("special");
Assert.IsTrue(childNodes.Count == 3);
for (var idx = 0; idx < 3; ++idx)
{
XmlNode currentNode = childNodes[idx];
switch (idx)
{
case 0:
Assert.IsNotNull(currentNode.Attributes["xmlns:palaso"]);
break;
case 1:
Assert.IsNotNull(currentNode.Attributes["xmlns:palaso2"]);
break;
case 2:
Assert.IsNotNull(currentNode.Attributes["xmlns:fw"]);
break;
}
Assert.IsNull(currentNode.Attributes["goner"]);
}
}
开发者ID:JessieGriffin,项目名称:chorus,代码行数:40,代码来源:LdmlFileMergeTests.cs
示例18: Do3WayMerge
/// <summary>
/// Do a 3-file merge, placing the result over the "ours" file and returning an error status
/// </summary>
/// <remarks>Implementations can exit with an exception, which the caller will catch and deal with.
/// The must not have any UI, no interaction with the user.</remarks>
public void Do3WayMerge(MergeOrder mergeOrder)
{
Guard.AgainstNull(mergeOrder, "mergeOrder");
if (mergeOrder == null)
throw new ArgumentNullException("mergeOrder");
var merger = new XmlMerger(mergeOrder.MergeSituation);
SetupElementStrategies(merger);
merger.EventListener = mergeOrder.EventListener;
using(var oursXml = new HtmlFileForMerging(mergeOrder.pathToOurs))
using(var theirsXml = new HtmlFileForMerging(mergeOrder.pathToTheirs))
using (var ancestorXml = new HtmlFileForMerging(mergeOrder.pathToCommonAncestor))
{
var result = merger.MergeFiles(oursXml.GetPathToXHtml(), theirsXml.GetPathToXHtml(), ancestorXml.GetPathToXHtml());
CarefullyWriteOutResultingXml(oursXml, result);
//now convert back to html
oursXml.SaveHtml();
}
}
开发者ID:BloomBooks,项目名称:BloomDesktop,代码行数:29,代码来源:BloomHtmlFileTypeHandler.cs
示例19: GetMerger
private static XmlMerger GetMerger(out ListenerForUnitTests listener, bool isAtomic)
{
var elementStrategy = new ElementStrategy(false)
{
IsAtomic = isAtomic
};
var merger = new XmlMerger(new NullMergeSituation());
merger.MergeStrategies.SetStrategy("topatomic", elementStrategy);
listener = new ListenerForUnitTests();
merger.EventListener = listener;
return merger;
}
开发者ID:JessieGriffin,项目名称:chorus,代码行数:12,代码来源:MergeAtomicElementServiceTests.cs
示例20: DeleteAtomicElementVsModifyHasConflict
public void DeleteAtomicElementVsModifyHasConflict()
{
const string commonAncestor =
@"<Lexicon>
<LexEntry guid='ffdc58c9-5cc3-469f-9118-9f18c0138d02'>
<MorphoSyntaxAnalyses>
<MoStemMsa
guid='33adabe9-a02e-42cb-b942-277a7be5c841'>
<PartOfSpeech>
<objsur
guid='e72dbc59-e93f-4df2-b6bd-39a53e331201'
t='r' />
</PartOfSpeech>
</MoStemMsa>
</MorphoSyntaxAnalyses>
<Senses/>
</LexEntry>
</Lexicon>";
const string matthew =
@"<Lexicon>
<LexEntry guid='ffdc58c9-5cc3-469f-9118-9f18c0138d02'>
<MorphoSyntaxAnalyses>
<MoStemMsa
guid='33adabe9-a02e-42cb-b942-277a7be5c841'>
<PartOfSpeech>
<objsur
guid='f92dbc59-e93f-4df2-b6bd-39a53e331201'
t='r' />
</PartOfSpeech>
</MoStemMsa>
</MorphoSyntaxAnalyses>
<Senses/>
</LexEntry>
</Lexicon>";
const string lee =
@"<Lexicon>
<LexEntry guid='ffdc58c9-5cc3-469f-9118-9f18c0138d02'>
<MorphoSyntaxAnalyses>
<MoStemMsa
guid='33adabe9-a02e-42cb-b942-277a7be5c841'>
<PartOfSpeech />
</MoStemMsa>
</MorphoSyntaxAnalyses>
<Senses/>
</LexEntry>
</Lexicon>";
var listener = new ListenerForUnitTests();
var merger = new XmlMerger(new NullMergeSituation())
{
EventListener = listener
};
merger.MergeStrategies.SetStrategy("Lexicon", ElementStrategy.CreateSingletonElement());
var strat = ElementStrategy.CreateForKeyedElement("guid", false);
strat.AttributesToIgnoreForMerging.Add("guid");
merger.MergeStrategies.SetStrategy("LexEntry", strat);
strat = ElementStrategy.CreateSingletonElement();
strat.NumberOfChildren = NumberOfChildrenAllowed.ZeroOrOne;
merger.MergeStrategies.SetStrategy("MorphoSyntaxAnalyses", strat);
strat = ElementStrategy.CreateForKeyedElement("guid", false);
strat.AttributesToIgnoreForMerging.Add("guid");
merger.MergeStrategies.SetStrategy("MoStemMsa", strat);
strat = ElementStrategy.CreateSingletonElement();
strat.NumberOfChildren = NumberOfChildrenAllowed.ZeroOrOne;
merger.MergeStrategies.SetStrategy("PartOfSpeech", strat);
strat = ElementStrategy.CreateSingletonElement();
strat.IsAtomic = true;
merger.MergeStrategies.SetStrategy("objsur", strat);
XmlTestHelper.DoMerge(merger.MergeStrategies,
merger.MergeSituation,
commonAncestor, lee, matthew,
new[] { "Lexicon/LexEntry/MorphoSyntaxAnalyses/MoStemMsa/PartOfSpeech/objsur[@guid='f92dbc59-e93f-4df2-b6bd-39a53e331201']" },
null,
1, new List<Type> { typeof(RemovedVsEditedElementConflict) },
0, new List<Type>());
}
开发者ID:JessieGriffin,项目名称:chorus,代码行数:82,代码来源:MergeAtomicElementServiceTests.cs
注:本文中的Chorus.merge.xml.generic.XmlMerger类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论