Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SecurityBypassContext" /> class.
        /// </summary>
        /// <param name="bypassSecurity">if set to <c>true</c> security is bypassed otherwise security is enabled.</param>
        public SecurityBypassContext(bool bypassSecurity)
        {
            BypassSecurity = bypassSecurity;

            _parent   = _current;
            _current  = this;
            _isActive = bypassSecurity;
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Releases unmanaged and - optionally - managed resources.
        /// </summary>
        /// <param name="disposing">
        ///     <c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.
        /// </param>
        // ReSharper disable UnusedParameter.Local
        private void Dispose(bool disposing)
        {
            if (!_disposed)
            {
                _current = _parent;

                if (_current == null)
                {
                    _isActive = false;
                }
                else
                {
                    _isActive = _current.BypassSecurity;
                }

                /////
                // Dispose complete.
                /////
                _disposed = true;
            }
        }