/// <summary> /// Create a new Entity Framework command interceptor using the provided configuration settings /// </summary> /// <param name="configuration"></param> private LoupeCommandInterceptor(EntityFrameworkElement configuration) { if (configuration == null) { throw new ArgumentNullException("configuration"); } _configuration = configuration; LogCallStack = _configuration.LogCallStack; LogExceptions = _configuration.LogExceptions; }
/// <summary> /// Register the Loupe Command Interceptor with Entity Framework (safe to call multiple times) /// </summary> public static void Register(EntityFrameworkElement configuration = null) { lock (s_Lock) { if (s_IsRegistered) { return; } s_IsRegistered = true; var effectiveConfiguration = configuration ?? EntityFrameworkElement.SafeLoad(); if (effectiveConfiguration.Enabled) { DbInterception.Add(new LoupeCommandInterceptor(effectiveConfiguration)); } } }