///-------------------------------------------------------------------------------------------------
 /// <summary>
 ///  Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged
 ///  resources.
 /// </summary>
 ///-------------------------------------------------------------------------------------------------
 public void Dispose()
 {
     if (_domain != null)
     {
         InnerGraph.DomainModel.Store.SessionCreated -= OnSessionCreated;
         _domain = null;
         _cache  = null;
     }
 }
        ///-------------------------------------------------------------------------------------------------
        /// <summary>
        ///  Constructor.
        /// </summary>
        /// <param name="domain">
        ///  The domain.
        /// </param>
        ///-------------------------------------------------------------------------------------------------
        public Level1Cache(DomainModel domain)
        {
            DebugContract.Requires(domain);

            _cache  = PlatformServices.Current.CreateConcurrentDictionary <Identity, IModelElement>();
            _domain = domain;

            InnerGraph.DomainModel.Store.SessionCreated += OnSessionCreated;
        }
        ///-------------------------------------------------------------------------------------------------
        /// <summary>
        ///  Constructor.
        /// </summary>
        /// <param name="services">
        ///  The services.
        /// </param>
        /// <param name="extendedDomain">
        ///  The extended domain.
        /// </param>
        ///-------------------------------------------------------------------------------------------------
        public ScopeHyperGraph(IServicesContainer services, IHyperGraphProvider extendedDomain)
            : base(services)
        {
            DebugContract.Requires(services);
            DebugContract.Requires(extendedDomain);

            _extendedDomain = extendedDomain;

            _extendedGraph = extendedDomain.InnerGraph as HyperGraph.HyperGraph;
            System.Diagnostics.Debug.Assert(_extendedGraph != null);
            _deletedElements = new Hyperstore.Modeling.MemoryStore.TransactionalMemoryStore(
                _extendedDomain.Name,
                5,
                _extendedDomain.Services.Resolve <Hyperstore.Modeling.MemoryStore.ITransactionManager>()
                );
        }