/// <summary> /// Resets the sorter so that it will use the writing system of the given reversal index. /// </summary> /// <param name="ri"></param> private void ResetListSorter(IReversalIndex ri) { var sorter = Sorter as GenRecordSorter; var writingSystem = (IWritingSystem)Cache.WritingSystemFactory.get_Engine(ri.WritingSystem); if (sorter != null) { var stringFinderComparer = sorter.Comparer as StringFinderCompare; if (stringFinderComparer != null) { var comparer = new StringFinderCompare(stringFinderComparer.Finder, new WritingSystemComparer(writingSystem)); sorter.Comparer = comparer; } } else if (Sorter == null) { var fakevc = new XmlBrowseViewBaseVc { SuppressPictures = true, Cache = Cache }; // SuppressPictures to make sure that we don't leak anything as this will not be disposed. m_list.Sorter = new GenRecordSorter(new StringFinderCompare(LayoutFinder.CreateFinder(Cache, BrowseViewFormCol, fakevc, (IApp)m_mediator.PropertyTable.GetValue("App")), new WritingSystemComparer(writingSystem))); } }
public void PersistReverseComparer() { string xml; // Putting an IntStringComparer here is utterly bizarre, but it tests out one more class. StringFinderCompare sfComp = new StringFinderCompare(new OwnMonoPropFinder(m_sda, 445), new ReverseComparer(new IntStringComparer())); sfComp.SortedFromEnd = true; // Save and restore! xml = DynamicLoader.PersistObject(sfComp, "comparer"); var doc = new XmlDocument(); doc.LoadXml(xml); // And check all the pieces... var sfCompOut = DynamicLoader.RestoreObject(doc.DocumentElement) as StringFinderCompare; m_objectsToDispose.Add(sfCompOut); sfCompOut.Cache = Cache; Assert.IsTrue(sfCompOut.Finder is OwnMonoPropFinder); Assert.IsTrue(sfCompOut.SubComparer is ReverseComparer); Assert.IsTrue(sfCompOut.SortedFromEnd); ReverseComparer rcOut = sfCompOut.SubComparer as ReverseComparer; Assert.IsTrue(rcOut.SubComp is IntStringComparer); }
public void SortersEtc() { PropertyRecordSorter prs = new PropertyRecordSorter("longName"); // Save and restore! string xml = DynamicLoader.PersistObject(prs, "sorter"); XmlDocument doc = new XmlDocument(); doc.LoadXml(xml); // And check all the pieces... PropertyRecordSorter prsOut = DynamicLoader.RestoreObject(doc.DocumentElement) as PropertyRecordSorter; prsOut.Cache = m_cache; Assert.AreEqual("longName", prsOut.PropertyName); // Putting an IntStringComparer here is utterly bizarre, but it tests out one more class. StringFinderCompare sfComp = new StringFinderCompare(new OwnMonoPropFinder(m_cache.MainCacheAccessor, 445), new ReverseComparer(new IntStringComparer())); sfComp.SortedFromEnd = true; // Save and restore! xml = DynamicLoader.PersistObject(sfComp, "comparer"); doc = new XmlDocument(); doc.LoadXml(xml); // And check all the pieces... StringFinderCompare sfCompOut = DynamicLoader.RestoreObject(doc.DocumentElement) as StringFinderCompare; sfCompOut.Cache = m_cache; Assert.IsTrue(sfCompOut.Finder is OwnMonoPropFinder); Assert.IsTrue(sfCompOut.SubComparer is ReverseComparer); Assert.IsTrue(sfCompOut.SortedFromEnd); ReverseComparer rcOut = sfCompOut.SubComparer as ReverseComparer; Assert.IsTrue(rcOut.SubComp is IntStringComparer); }