Esempio n. 1
0
 public void Dispose()
 {
     if (_sopReference != null)
     {
         _sopReference.Dispose();
         _sopReference = null;
     }
 }
Esempio n. 2
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (_sopReference != null)
         {
             _sopReference.Dispose();
             _sopReference = null;
         }
     }
     base.Dispose(disposing);
 }
Esempio n. 3
0
        public void TestReferences2()
        {
            IList <DicomAttributeCollection> collections = base.SetupMRSeries(1, 1, "test");
            DicomFile      file       = new DicomFile(null, new DicomAttributeCollection(), collections[0]);
            TestDataSource dataSource = new TestDataSource(file);
            Sop            sop        = Sop.Create(dataSource);

            ISopReference reference1 = sop.CreateTransientReference();
            ISopReference reference2 = sop.CreateTransientReference();

            sop.Dispose();
            Assert.IsFalse(dataSource.IsDisposed);
            Assert.IsFalse(SopDataCache.ItemCount == 0, "The Sop data cache is NOT empty.");

            reference1.Dispose();
            Assert.IsFalse(dataSource.IsDisposed);
            Assert.IsFalse(SopDataCache.ItemCount == 0, "The Sop data cache is NOT empty.");

            reference2.Dispose();
            Assert.IsTrue(dataSource.IsDisposed);
            Assert.IsTrue(SopDataCache.ItemCount == 0, "The Sop data cache is NOT empty.");
        }
Esempio n. 4
0
        public void TestCaching()
        {
            IList <DicomAttributeCollection> collections = base.SetupMRSeries(1, 1, "test");
            DicomFile file1 = new DicomFile(null, new DicomAttributeCollection(), collections[0].Copy());
            DicomFile file2 = new DicomFile(null, new DicomAttributeCollection(), collections[0].Copy());

            TestDataSource dataSource1 = new TestDataSource(file1);
            TestDataSource dataSource2 = new TestDataSource(file2);

            Sop sop1 = Sop.Create(dataSource1);

            Assert.IsTrue(SopDataCache.ItemCount == 1, "The Sop data cache should have 1 entry.");

            Sop sop2 = Sop.Create(dataSource2);

            Assert.IsTrue(SopDataCache.ItemCount == 1, "The Sop data cache should have 1 entry.");
            Assert.IsTrue(dataSource2.IsDisposed, "The data source has not been disposed.");
            Assert.IsFalse(dataSource1.IsDisposed, "The data source should not be disposed.");

            sop1.Dispose();
            Assert.IsTrue(SopDataCache.ItemCount == 1, "The Sop data cache should have 1 entry.");

            ISopReference reference21 = sop2.CreateTransientReference();
            ISopReference reference22 = sop2.CreateTransientReference();

            reference21.Dispose();
            Assert.IsFalse(dataSource1.IsDisposed, "The data source has been disposed.");
            Assert.IsTrue(SopDataCache.ItemCount == 1, "The Sop data cache should have 1 entry.");

            sop2.Dispose();
            Assert.IsFalse(dataSource1.IsDisposed, "The data source has been disposed.");
            Assert.IsTrue(SopDataCache.ItemCount == 1, "The Sop data cache should have 1 entry.");

            reference22.Dispose();
            Assert.IsTrue(dataSource1.IsDisposed, "The data source has not been disposed.");
            Assert.IsTrue(SopDataCache.ItemCount == 0, "The Sop data cache is NOT empty.");
        }