示例#1
0
        // IDisposable implementation

        /// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
        /// </summary>
        public void Dispose()
        {
            if (isDisposed)
            {
                return;
            }
            try {
                OrmLog.Debug(Strings.LogSessionXDisposing, this);

                SystemEvents.NotifyDisposing();
                Events.NotifyDisposing();

                Services.DisposeSafely();
                Handler.DisposeSafely();
                CommandProcessorContextProvider.DisposeSafely();

                Domain.ReleaseSingleConnection();

                disposableSet.DisposeSafely();
                disposableSet = null;

                EntityChangeRegistry.Clear();
                EntitySetChangeRegistry.Clear();
                EntityStateCache.Clear();
                ReferenceFieldsChangesRegistry.Clear();
                NonPairedReferencesRegistry.Clear();
            }
            finally {
                isDisposed = true;
            }
        }
示例#2
0
        private async ValueTask DisposeImpl(bool isAsync)
        {
            if (isDisposed)
            {
                return;
            }

            sessionLifetimeToken.Expire();

            try {
                if (IsDebugEventLoggingEnabled)
                {
                    OrmLog.Debug(Strings.LogSessionXDisposing, this);
                }

                SystemEvents.NotifyDisposing();
                Events.NotifyDisposing();

                Services.DisposeSafely();
                if (isAsync)
                {
                    await Handler.DisposeSafelyAsync().ConfigureAwait(false);
                }
                else
                {
                    Handler.DisposeSafely();
                }
                CommandProcessorContextProvider.DisposeSafely();

                Domain.ReleaseSingleConnection();

                disposableSet.DisposeSafely();
                disposableSet = null;

                EntityChangeRegistry.Clear();
                EntitySetChangeRegistry.Clear();
                EntityStateCache.Clear();
                ReferenceFieldsChangesRegistry.Clear();
                NonPairedReferencesRegistry.Clear();
                Extensions.Clear();
            }
            finally {
                isDisposed = true;
            }
        }