Ejemplo n.º 1
0
        public void CouldCompareDates()
        {
            var dtc = KeyComparer.GetDefault <DateTime>();
            var neg = dtc.Compare(DateTime.Today.AddDays(-2), DateTime.Today);
            var pos = dtc.Compare(DateTime.Today.AddDays(2), DateTime.Today.AddDays(-2));

            Console.WriteLine(neg);
            Assert.IsTrue(neg < 0);

            Console.WriteLine(pos);
            Assert.IsTrue(pos > 0);
        }
Ejemplo n.º 2
0
        protected SortedChunkedMap<K, V> GetSeries<K, V>(long seriesId, long version, bool readOnly, int chunkSize = 4096) {
            SortedChunkedMap<K, V> series;
            var comparer = KeyComparer.GetDefault<K>() as IKeyComparer<K>;
            if (comparer == null) throw new NotSupportedException("Only type that have IKeyComparer<K> are supported");
            Func<IComparer<K>, IOrderedMap<K, SortedMap<K, V>>> outerFactory =
                cmp => new RemoteChunksSeries<K, V>(
                    seriesId,
                    cmp as IKeyComparer<K>,
                    LoadKeys,
                    LoadChunk,
                    SaveChunk,
                    RemoveChunk,
                    version,
                    readOnly);

            series = new SortedChunkedMap<K, V>(outerFactory, comparer, chunkSize) {
                // better be safe
                IsSynchronized = true
            };
            // NB important to set the version here because SCM does not initialize its version from outer
            series.Version = version;
            return series;
        }