private static string MakeHtmlForIncompatibleMove(IConflict conflict, string oldGuid, string elementGuid, XElement element) { var doc = new XmlDocument(); doc.LoadXml(element.ToString()); var sb = new StringBuilder("<head><style type='text/css'>"); sb.Append(FieldWorkObjectContextGenerator.DefaultHtmlContextStyles(doc.DocumentElement)); sb.Append("</style></head><body><div class='description'>"); sb.Append(conflict.GetFullHumanReadableDescription()); string className = element.Name.LocalName; var classAttr = element.Attribute("class"); if (classAttr != null) { className = classAttr.Value; } sb.Append(String.Format("</div><div> The object that was copied is a {0}:", className)); sb.Append("</div><div class=\"description\">"); sb.Append(new FwGenericHtmlGenerator().MakeHtml(doc.DocumentElement)); sb.Append("</div><div>The original is "); MakeSilfwLink(oldGuid, sb); sb.Append("</div><div>The copy is "); MakeSilfwLink(elementGuid, sb); sb.Append("</div></body>"); return(sb.ToString()); }
public void UnknownMultiStringDefaultSingleAlternative() { string source = @"<RootClass> <HomographNumber val='0' /> <Outer> <Mid> <Target> <AUni ws='en'>abcdefghijk</AUni> </Target> <IsAbstract val='False' /> <MorphType> <objsur guid='d7f713e4-e8cf-11d3-9764-00c04f186933' t='r' /> </MorphType> </Mid> </Outer> </RootClass>" ; var root = GetNode(source); var input = root.ChildNodes[1].ChildNodes[0].ChildNodes[0]; // the Target element. var generator = new FieldWorkObjectContextGenerator(); var html = generator.HtmlContext(input); Assert.That(html, Is.EqualTo("<span class=\"ws\">en</span>: abcdefghijk")); // Get exactly the same starting from one of the AUni children. var input2 = input.ChildNodes[0]; html = generator.HtmlContext(input2); Assert.That(html, Is.EqualTo("<span class=\"ws\">en</span>: abcdefghijk")); }
public void UnicodeStringJustShowsText() { string source = @"<RootClass> <HomographNumber val='0' /> <Outer> <Mid> <Target> <Uni>abcdefghijk</Uni> </Target> </Mid> </Outer> </RootClass>" ; var root = GetNode(source); var input = root.ChildNodes[1].ChildNodes[0].ChildNodes[0]; // the Target element. var generator = new FieldWorkObjectContextGenerator(); var html = generator.HtmlContext(input); Assert.That(html, Is.EqualTo("abcdefghijk")); // Get exactly the same starting from the Uni child. var input2 = input.ChildNodes[0]; html = generator.HtmlContext(input2); Assert.That(html, Is.EqualTo("abcdefghijk")); }
public void LastResortIsGenericHtmlGenerator() { string source = @"<RootClass> <Outer> <Mid> <Target> some rubbish </Target> </Mid> </Outer> </RootClass>" ; var root = GetNode(source); var input = root.ChildNodes[0].ChildNodes[0].ChildNodes[0]; // the Target element. var generator = new FieldWorkObjectContextGenerator(); var html = generator.HtmlContext(input); Assert.That(html, Is.EqualTo(new FwGenericHtmlGenerator().MakeHtml(input))); }
private static void MakeClassStrategy(MergeStrategies strategiesForMerger, FdoClassInfo classInfo, FieldWorkObjectContextGenerator defaultDescriptor) { Guard.AgainstNull(defaultDescriptor, "defaultDescriptor"); // These values can be overridden or added to in the big switch, below. var classStrat = new ElementStrategy(false) { ContextDescriptorGenerator = defaultDescriptor, MergePartnerFinder = GuidKeyFinder, IsAtomic = false }; strategiesForMerger.SetStrategy(classInfo.ClassName, classStrat); // Try to keep these in alphbetical order, and where there are 'blocks', then try to keep the blocks in order. // That will make them easier to find. switch (classInfo.ClassName) { case "CmPossibilityList": classStrat.ContextDescriptorGenerator = new PossibilityListContextGenerator(); break; case "FsClosedFeature": classStrat.ContextDescriptorGenerator = new MultiLingualStringsContextGenerator("Phonological Features", "Name", "Abbreviation"); break; case "FsFeatStruc": classStrat.IsAtomic = true; break; case "LangProject": classStrat.ContextDescriptorGenerator = new LanguageProjectContextGenerator(); break; case "LexEntry": classStrat.ContextDescriptorGenerator = new LexEntryContextGenerator(); break; case "PhEnvironment": classStrat.ContextDescriptorGenerator = new EnvironmentContextGenerator(); break; case "PhNCSegments": classStrat.ContextDescriptorGenerator = new MultiLingualStringsContextGenerator("Natural Class", "Name", "Abbreviation"); break; case "ReversalIndexEntry": classStrat.ContextDescriptorGenerator = new ReversalEntryContextGenerator(); break; case "RnGenericRec": classStrat.ContextDescriptorGenerator = new RnGenericRecContextGenerator(); break; case "ScrBook": classStrat.ContextDescriptorGenerator = new ScrBookContextGenerator(); break; case "ScrDraft": // ScrDraft instances can only be added or removed, but not changed, according to John Wickberg (18 Jan 2012). classStrat.IsImmutable = true; break; case "ScrSection": classStrat.ContextDescriptorGenerator = new ScrSectionContextGenerator(); break; case "ScrTxtPara": // Fall through. case "StTxtPara": // This will never be used, since StTxtParas & ScrTxtParas are actually in an 'ownseq' element. classStrat.Premerger = new StTxtParaPremerger(); // Didn't work, since StTxtParas & ScrTxtParas are actually in an 'ownseq' element. // classStrat.IsAtomic = true; break; case "Text": classStrat.ContextDescriptorGenerator = new TextContextGenerator(); break; case "WfiWordform": classStrat.ContextDescriptorGenerator = new WfiWordformContextGenerator(); break; // These should be all the subclasses of CmPossiblity. It's unfortuate to have to list them here; // OTOH, if we ever want special handling for any of them, we can easily add a special generator. // Note that these will not usually be found as strategies, since they are owned in owning sequences // and ownseq has its own item. However, they can be found by the default object context generator code, // which has a special case for ownseq. case "ChkTerm": case "CmAnthroItem": case "CmAnnotationDefn": case "CmCustomItem": case "CmLocation": case "CmPerson": case "CmPossibility": case "CmSemanticDomain": case "LexEntryType": case "LexRefType": case "MoMorphType": case "PartOfSpeech": case "PhPhonRuleFeat": classStrat.ContextDescriptorGenerator = new PossibilityContextGenerator(); break; case "ConstChartRow": case "ConstChartWordGroup": case "DsConstChart": classStrat.ContextDescriptorGenerator = new DiscourseChartContextGenerator(); break; } ((FieldWorkObjectContextGenerator)classStrat.ContextDescriptorGenerator).MergeStrategies = strategiesForMerger; }