Example #1
0
 public Context(DbConnection connection)
     : base(new DbContextOptionsBuilder <Context>().UseJet(connection).Options)
 {
     // NOT THE RIGHT PLACE TO DO THIS!!!
     _dbTreeInterceptor = new TenantCommandTreeInterceptor();
     DbInterception.Add(_dbTreeInterceptor);
 }
Example #2
0
 public Context(DbConnection connection)
     : base(connection, false)
 {
     // NOT THE RIGHT PLACE TO DO THIS!!!
     _dbTreeInterceptor = new TenantCommandTreeInterceptor();
     DbInterception.Add(_dbTreeInterceptor);
 }
Example #3
0
 public static void Add(IDbInterceptor interceptor)
 {
     if (!interceptors.Contains(interceptor))
     {
         interceptors.Add(interceptor);
     }
 }
Example #4
0
        protected internal void Interceptor(IDbInterceptor interceptor)
        {
            Check.NotNull(interceptor, "interceptor");

            _internalConfiguration.CheckNotLocked("Interceptor");
            _internalConfiguration.RegisterSingleton(interceptor);
        }
 public static void Add(IDbInterceptor interceptor)
 {
     lock (Sync)
     {
         interceptors = interceptors.Concat(new[] { interceptor }).ToArray();
     }
 }
 public CarsContext(DbConnection connection)
     : base(connection, false)
 {
     _dbInterceptor     = new DbCommandInterceptor();
     _dbTreeInterceptor = new DbCommandTreeInterceptor();
     DbInterception.Add(_dbInterceptor);
     DbInterception.Add(_dbTreeInterceptor);
 }
 public CarsContext(DbConnection connection)
     : base(new DbContextOptionsBuilder <CarsContext>().UseJet(connection).Options)
 {
     _dbInterceptor     = new DbCommandInterceptor();
     _dbTreeInterceptor = new DbCommandTreeInterceptor();
     DbInterception.Add(_dbInterceptor);
     DbInterception.Add(_dbTreeInterceptor);
 }
Example #8
0
 public bool RemoveInterceptor(IDbInterceptor interceptor)
 {
     if (this.interceptors.Contains(interceptor))
     {
         this.interceptors.Remove(interceptor);
         return(true);
     }
     return(false);
 }
Example #9
0
        internal virtual void RemoveInterceptor(IDbInterceptor interceptor)
        {
            DebugCheck.NotNull(interceptor);

            _commandTreeDispatcher.InternalDispatcher.Remove(interceptor);
            _commandDispatcher.InternalDispatcher.Remove(interceptor);
            _entityConnectionDispatcher.InternalDispatcher.Remove(interceptor);
            _cancelableCommandDispatcher.InternalDispatcher.Remove(interceptor);
        }
        internal virtual void RemoveInterceptor(IDbInterceptor interceptor)
        {
            DebugCheck.NotNull(interceptor);

            _commandTreeDispatcher.InternalDispatcher.Remove(interceptor);
            _commandDispatcher.InternalDispatcher.Remove(interceptor);
            _entityConnectionDispatcher.InternalDispatcher.Remove(interceptor);
            _cancelableCommandDispatcher.InternalDispatcher.Remove(interceptor);
        }
Example #11
0
 internal virtual void AddInterceptor(IDbInterceptor interceptor)
 {
     this._commandTreeDispatcher.InternalDispatcher.Add(interceptor);
     this._commandDispatcher.InternalDispatcher.Add(interceptor);
     this._transactionDispatcher.InternalDispatcher.Add(interceptor);
     this._dbConnectionDispatcher.InternalDispatcher.Add(interceptor);
     this._cancelableEntityConnectionDispatcher.InternalDispatcher.Add(interceptor);
     this._cancelableCommandDispatcher.InternalDispatcher.Add(interceptor);
     this._configurationDispatcher.InternalDispatcher.Add(interceptor);
 }
Example #12
0
        internal virtual void AddInterceptor(IDbInterceptor interceptor)
        {
            DebugCheck.NotNull(interceptor);

            _commandTreeDispatcher.InternalDispatcher.Add(interceptor);
            _commandDispatcher.InternalDispatcher.Add(interceptor);
            _transactionDispatcher.InternalDispatcher.Add(interceptor);
            _dbConnectionDispatcher.InternalDispatcher.Add(interceptor);
            _cancelableEntityConnectionDispatcher.InternalDispatcher.Add(interceptor);
            _cancelableCommandDispatcher.InternalDispatcher.Add(interceptor);
        }
Example #13
0
        internal virtual void AddInterceptor(IDbInterceptor interceptor)
        {
            DebugCheck.NotNull(interceptor);

            _commandTreeDispatcher.InternalDispatcher.Add(interceptor);
            _commandDispatcher.InternalDispatcher.Add(interceptor);
            _transactionDispatcher.InternalDispatcher.Add(interceptor);
            _dbConnectionDispatcher.InternalDispatcher.Add(interceptor);
            _cancelableEntityConnectionDispatcher.InternalDispatcher.Add(interceptor);
            _cancelableCommandDispatcher.InternalDispatcher.Add(interceptor);
            _configurationDispatcher.InternalDispatcher.Add(interceptor);
        }
Example #14
0
        public void Remove(IDbInterceptor interceptor)
        {
            TInterceptor interceptor1 = interceptor as TInterceptor;

            if ((object)interceptor1 == null)
            {
                return;
            }
            lock (this._lock)
            {
                List <TInterceptor> list = this._interceptors.ToList <TInterceptor>();
                list.Remove(interceptor1);
                this._interceptors = list;
            }
        }
Example #15
0
        public void Remove(IDbInterceptor interceptor)
        {
            DebugCheck.NotNull(interceptor);

            var asThisType = interceptor as TInterceptor;

            if (asThisType == null)
            {
                return;
            }

            lock (_lock)
            {
                var newList = _interceptors.ToList();
                newList.Remove(asThisType);
                _interceptors = newList;
            }
        }
Example #16
0
        public virtual IDbInterceptor CreateInterceptor()
        {
            object instance;

            try
            {
                instance = Activator.CreateInstance(Type.GetType(this.TypeName, true), this.Parameters.GetTypedParameterValues());
            }
            catch (Exception ex)
            {
                throw new InvalidOperationException(Strings.InterceptorTypeNotFound((object)this.TypeName), ex);
            }
            IDbInterceptor dbInterceptor = instance as IDbInterceptor;

            if (dbInterceptor == null)
            {
                throw new InvalidOperationException(Strings.InterceptorTypeNotInterceptor((object)this.TypeName));
            }
            return(dbInterceptor);
        }
        /// <summary>
        ///     Removes a registered <see cref="IDbInterceptor" /> so that it will no longer receive notifications.
        ///     If the given interceptor is not registered, then this is a no-op.
        /// </summary>
        /// <param name="interceptor">The interceptor to remove.</param>
        public static void RemoveInterceptor(IDbInterceptor interceptor)
        {
            Check.NotNull(interceptor, "interceptor");

            _dispatchers.RemoveInterceptor(interceptor);
        }
Example #18
0
 public static void Remove(IDbInterceptor interceptor)
 {
     interceptors.Remove(interceptor);
 }
Example #19
0
 // ReSharper disable once SuggestBaseTypeForParameter
 public AppDbContext(DbContextOptions <AppDbContext> options) : base(options)
 {
     _interceptor = this.GetService <IDbInterceptor>();
 }
Example #20
0
 /// <summary>
 /// Removes a registered <see cref="T:System.Data.Entity.Infrastructure.Interception.IDbInterceptor" /> so that it will no longer receive notifications.
 /// If the given interceptor is not registered, then this is a no-op.
 /// </summary>
 /// <param name="interceptor">The interceptor to remove.</param>
 public static void Remove(IDbInterceptor interceptor)
 {
     Check.NotNull <IDbInterceptor>(interceptor, nameof(interceptor));
     DbInterception._dispatchers.Value.RemoveInterceptor(interceptor);
 }
Example #21
0
        /// <summary>
        /// Registers a new <see cref="IDbInterceptor" /> to receive notifications. Note that the interceptor
        /// must implement some interface that extends from <see cref="IDbInterceptor" /> to be useful.
        /// </summary>
        /// <param name="interceptor">The interceptor to add.</param>
        public static void Add(IDbInterceptor interceptor)
        {
            Check.NotNull(interceptor, "interceptor");

            _dispatchers.Value.AddInterceptor(interceptor);
        }
        /// <summary>
        /// Registers a new <see cref="IDbInterceptor" /> to receive notifications. Note that the interceptor
        /// must implement some interface that extends from <see cref="IDbInterceptor" /> to be useful.
        /// </summary>
        /// <param name="interceptor">The interceptor to add.</param>
        public static void Add(IDbInterceptor interceptor)
        {
            Check.NotNull(interceptor, "interceptor");

            _dispatchers.Value.AddInterceptor(interceptor);
        }
Example #23
0
        public bool RemoveInterceptor(IDbInterceptor interceptor)
        {
            Guard.IsNull(interceptor);

            return(this.interceptionManager.RemoveInterceptor(interceptor));
        }
Example #24
0
        public void AddInterceptor(IDbInterceptor interceptor)
        {
            Guard.IsNull(interceptor);

            this.interceptionManager.AddInterceptor(interceptor);
        }
Example #25
0
 public ISession OpenSession(IDbInterceptor sessionLocalInterceptor)
 {
     throw new NotImplementedException();
 }
 public void RemoveInterceptor(IDbInterceptor dbInterceptor) => interceptors.Remove(dbInterceptor);
 public void AddInterceptor(IDbInterceptor dbInterceptor) => interceptors.Add(dbInterceptor);
Example #28
0
 public void AddInterceptor(IDbInterceptor interceptor)
 {
     this.interceptors.Add(interceptor);
 }
Example #29
0
        /// <summary>
        ///     Removes a registered <see cref="IDbInterceptor" /> so that it will no longer receive notifications.
        ///     If the given interceptor is not registered, then this is a no-op.
        /// </summary>
        /// <param name="interceptor">The interceptor to remove.</param>
        public static void RemoveInterceptor(IDbInterceptor interceptor)
        {
            Check.NotNull(interceptor, "interceptor");

            _dispatchers.Value.RemoveInterceptor(interceptor);
        }