Ejemplo n.º 1
0
        private void AttachHooks(IHook[] hooks)
        {
            if (hooks == null) {
                InitializeHooks();
                return;
            };

            PreHooks = hooks.OfType<IPreActionHook>().ToList();
            PostHooks = hooks.OfType<IPostActionHook>().ToList();
            PostLoadHooks = hooks.OfType<IPostLoadHook>().ToList();
        }
Ejemplo n.º 2
0
 public HookedDbContext(IHook[] hooks)
 {
     PreHooks = hooks.OfType<IPreActionHook>().ToList();
     PostHooks = hooks.OfType<IPostActionHook>().ToList();
 }
Ejemplo n.º 3
0
 public HookedDbContext(IHook[] hooks, string nameOrConnectionString)
     : base(nameOrConnectionString)
 {
     PreHooks = hooks.OfType<IPreActionHook>().ToList();
     PostHooks = hooks.OfType<IPostActionHook>().ToList();
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HookedDbContext" /> class using the an existing connection to connect 
 /// to a database. The connection will not be disposed when the context is disposed. (see <see cref="DbContext"/> overloaded constructor)
 /// </summary>
 /// <param name="hooks">The hooks.</param>
 /// <param name="existingConnection">An existing connection to use for the new context.</param>
 /// <param name="contextOwnsConnection">If set to true the connection is disposed when the context is disposed, otherwise the caller must dispose the connection.</param>
 /// <remarks>Main reason for allowing this, is to enable reusing another database connection. (For instance one that is profiled by Miniprofiler (http://miniprofiler.com/)).</remarks>
 public HookedDbContext(IHook[] hooks, DbConnection existingConnection, bool contextOwnsConnection)
     : base(existingConnection, contextOwnsConnection)
 {
     PreHooks = hooks.OfType<IPreActionHook>().ToList();
     PostHooks = hooks.OfType<IPostActionHook>().ToList();
 }