public void Dispose()
 {
     _shapeInstanceTransaction.Dispose();
     _shapeGeometryTransaction.Dispose();
     if (_shapeGeometryCursor != null)
     {
         _esentModel.FreeTable(_shapeGeometryCursor);
     }
     if (_shapeInstanceCursor != null)
     {
         _esentModel.FreeTable(_shapeInstanceCursor);
     }
 }
        public EsentGeometryStoreReader(EsentModel esentModel)
        {
            _esentModel               = esentModel;
            _shapeGeometryCursor      = _esentModel.GetShapeGeometryTable();
            _shapeInstanceCursor      = _esentModel.GetShapeInstanceTable();
            _shapeGeometryTransaction = _shapeGeometryCursor.BeginReadOnlyTransaction();
            _shapeInstanceTransaction = _shapeInstanceCursor.BeginReadOnlyTransaction();
            _regionsList              = new XbimContextRegionCollection();
            IXbimShapeGeometryData regions = new XbimRegionCollection();

            if (_shapeGeometryCursor.TryMoveFirstRegion(ref regions))
            {
                do
                {
                    _regionsList.Add((XbimRegionCollection)regions);
                    regions = new XbimRegionCollection();
                } while (_shapeGeometryCursor.TryMoveNextRegion(ref regions));
            }
            if (!_regionsList.Any()) //we might have an old xbim database regions were stored in the geometry table
            {
                var legacyCursor = _esentModel.GetGeometryTable();
                using (var txn = legacyCursor.BeginReadOnlyTransaction())
                {
                    foreach (var regionData in legacyCursor.GetGeometryData(Xbim.Common.Geometry.XbimGeometryType.Region))
                    {
                        _regionsList.Add(XbimRegionCollection.FromArray(regionData.ShapeData));
                    }
                }
                _esentModel.FreeTable(legacyCursor);
            }
            _contextIds = new HashSet <int>(ContextIds);
        }
Esempio n. 3
0
 public IGeometryStoreInitialiser BeginInit()
 {
     try
     {
         if (_currentTransaction == null) //we can start a new one
         {
             //dispose of any tables because we are going to clear them
             if (_shapeGeometryCursor != null)
             {
                 _shapeGeometryCursor.Dispose();
                 _shapeGeometryCursor = null;
             }
             if (_shapeInstanceCursor != null)
             {
                 _shapeInstanceCursor.Dispose();
                 _shapeInstanceCursor = null;
             }
             //delete any geometries in the database
             _esentModel.ClearGeometryTables();
             _shapeGeometryCursor = _esentModel.GetShapeGeometryTable();
             _shapeInstanceCursor = _esentModel.GetShapeInstanceTable();
             _currentTransaction  = new EsentGeometryInitialiser(this, _shapeGeometryCursor, _shapeInstanceCursor);
             return(_currentTransaction);
         }
         throw new Exception("A transaction is in operation on the geometry store");
     }
     catch (Exception e)
     {
         if (_shapeGeometryCursor != null)
         {
             _esentModel.FreeTable(_shapeGeometryCursor);
         }
         if (_shapeInstanceCursor != null)
         {
             _esentModel.FreeTable(_shapeInstanceCursor);
         }
         _currentTransaction = null;
         throw new Exception("Begin initialisation failed on Geometry Store", e);
     }
 }