Inheritance: PersistentCounter
Ejemplo n.º 1
0
        public void DualCounterTest()
        {
            string filePath = "c:\\temp\\test";

            DocCounter docCounter= new DocCounter(filePath);
            SequenceCounter sequenceCounter= new SequenceCounter(filePath);

            docCounter.Reset();
            sequenceCounter.Reset();

            long docCount = docCounter.Get();
            Assert.AreEqual(0, docCount);
            docCount = docCounter.Next();
            Assert.AreEqual(1, docCount);

            long sequenceCount = sequenceCounter.Get();
            Assert.AreEqual(0, sequenceCount);
            sequenceCount = sequenceCounter.Next();
            Assert.AreEqual(1, sequenceCount);

            docCounter.Close();

            docCounter = new DocCounter(filePath);
            docCount = docCounter.Get();
            Assert.AreEqual(1, docCount);
        }
Ejemplo n.º 2
0
        public void Open(string storeName, string basePath = BASE_PATH, Dictionary <string, string> options = null)
        {
            this.storeName = storeName;
            DBLockManager manager = DBLockManager.Instance;

            if (!basePath.EndsWith("\\"))
            {
                basePath += "\\";
            }
            this.storeBasePath = basePath;

            // stores the revision history for a given document
            docStore = manager.GetDB(basePath + storeName + "\\docStore");

            // stores the specific revision id and data for a given document
            sequenceStore = manager.GetDB(basePath + storeName + "\\sequenceStore");

            attachStore       = manager.GetDB(basePath + storeName + "\\attachStore");
            attachBinaryStore = manager.GetDB(basePath + storeName + "\\attachBinaryStore");

            docCounter      = new DocCounter(basePath + storeName);
            docCount        = docCounter.Get();
            sequenceCounter = new SequenceCounter(basePath + storeName);
            sequenceCount   = sequenceCounter.Get();

            opened = true;
        }
Ejemplo n.º 3
0
        public void DocCounterTest()
        {
            string filePath = "c:\\temp\\test";

            DocCounter counter = new DocCounter(filePath);
            counter.Reset();
            long count = counter.Get();
            Assert.AreEqual(0, count);
            count = counter.Next();
            Assert.AreEqual(1, count);
            count = counter.Next();
            Assert.AreEqual(2, count);
            counter.Close();

            counter = null;

            counter = new DocCounter(filePath);
            count = counter.Get();
            Assert.AreEqual(2, count);
        }
Ejemplo n.º 4
0
        public void Open(string storeName, string basePath = BASE_PATH, Dictionary<string, string> options = null)
        {
            this.storeName = storeName;
            DBLockManager manager = DBLockManager.Instance;

            if (!basePath.EndsWith("\\"))
            {
                basePath += "\\";
            }
            this.storeBasePath = basePath;

            // stores the revision history for a given document
            docStore = manager.GetDB(basePath + storeName+"\\docStore");

            // stores the specific revision id and data for a given document
            sequenceStore = manager.GetDB(basePath + storeName + "\\sequenceStore");

            attachStore = manager.GetDB(basePath + storeName + "\\attachStore");
            attachBinaryStore = manager.GetDB(basePath + storeName + "\\attachBinaryStore");

            docCounter = new DocCounter( basePath + storeName);
            docCount = docCounter.Get();
            sequenceCounter = new SequenceCounter(basePath + storeName);
            sequenceCount= sequenceCounter.Get();

            opened = true;
        }