Example #1
0
		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);
		}
Example #2
0
		private IComparer UnpackReverseCompare(StringFinderCompare sfc)
		{
			IComparer subComp = sfc.SubComparer;
			if (subComp is ReverseComparer)
				subComp = (subComp as ReverseComparer).SubComp;
			return subComp;
		}
Example #3
0
		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);
		}
Example #4
0
		/// <summary>
		/// Copy our comparer's SubComparer and SortedFromEnd to another comparer.
		/// </summary>
		/// <param name="copyComparer"></param>
		public void CopyTo(StringFinderCompare copyComparer)
		{
			copyComparer.m_subComp = this.m_subComp is ICloneable ? ((ICloneable)m_subComp).Clone() as IComparer : m_subComp;
			copyComparer.m_fSortedFromEnd = this.m_fSortedFromEnd;
			copyComparer.m_fSortedByLength = this.m_fSortedByLength;
		}
Example #5
0
		/// <summary>
		/// Copy our comparer's SubComparer and SortedFromEnd to another comparer.
		/// </summary>
		/// <param name="copyComparer"></param>
		public void CopyTo(StringFinderCompare copyComparer)
		{
			CheckDisposed();

			copyComparer.m_subComp = this.m_subComp;
			copyComparer.m_fSortedFromEnd = this.m_fSortedFromEnd;
			copyComparer.m_fSortedByLength = this.m_fSortedByLength;
		}