/// <summary>
        /// Initializes a new instance of the <see cref="InstrumentedDbDataAdapter"/> class.
        /// </summary>
        /// <param name="wrappedAdapter">The wrapped adapter.</param>
        /// <param name="instrumentationHandler"></param>
        /// <exception cref="ArgumentNullException">Throws when the <paramref name="wrappedAdapter"/> is <c>null</c>.</exception>
        public InstrumentedDbDataAdapter(IDbDataAdapter wrappedAdapter, IInstrumentationHandler instrumentationHandler = null)
        {
            this.InternalAdapter         = wrappedAdapter ?? throw new ArgumentNullException(nameof(wrappedAdapter));
            this._instrumentationHandler = instrumentationHandler;

            this.InitCommands(wrappedAdapter);
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="InstrumentedDbConnection"/> class.
        /// Returns a new <see cref="InstrumentedDbConnection"/> that wraps <paramref name="connection"/>,
        /// providing query execution profiling. If profiler is null, no profiling will occur.
        /// </summary>
        /// <param name="connection"><c>Your provider-specific flavour of connection, e.g. SqlConnection, OracleConnection</c></param>
        /// <param name="instrumentationHandler">The currently started <see cref="InstrumentationHandler"/> or null.</param>
        /// <exception cref="ArgumentNullException">Throws when <paramref name="connection"/> is <c>null</c>.</exception>
        public InstrumentedDbConnection(DbConnection connection, IInstrumentationHandler instrumentationHandler)
        {
            this._connection              = connection ?? throw new ArgumentNullException(nameof(connection));
            this._connection.StateChange += this.StateChangeHandler;

            if (instrumentationHandler != null)
            {
                this._instrumentationHandler = instrumentationHandler;
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="InstrumentedDbCommand"/> class.
        /// </summary>
        /// <param name="command">The command.</param>
        /// <param name="connection">The connection.</param>
        /// <param name="profiler">The profiler.</param>
        /// <param name="instrumentationHandler">A handler to handle instrumentation events</param>
        /// <exception cref="ArgumentNullException">Throws when <paramref name="command"/> is <c>null</c>.</exception>
        public InstrumentedDbCommand(DbCommand command, DbConnection connection, IInstrumentationHandler instrumentationHandler)
        {
            this._command = command ?? throw new ArgumentNullException(nameof(command));
            this._instrumentationHandler = instrumentationHandler;

            if (connection != null)
            {
                this._connection = connection;
                this.UnwrapAndAssignConnection(connection);
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="InstrumentedDbDataReader"/> class.
 /// </summary>
 /// <param name="reader">The reader.</param>
 /// <param name="behavior">The behavior specified during command execution.</param>
 /// <param name="instrumentationHandler">The instrumentationHandler.</param>
 public InstrumentedDbDataReader(DbDataReader reader, CommandBehavior behavior, IInstrumentationHandler instrumentationHandler)
 {
     this.WrappedReader           = reader;
     this.Behavior                = behavior;
     this._instrumentationHandler = instrumentationHandler;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="InstrumentedDbDataReader"/> class (with <see cref="CommandBehavior.Default"/>).
 /// </summary>
 /// <param name="reader">The reader.</param>
 /// <param name="instrumentationHandler">The instrumentationHandler.</param>
 public InstrumentedDbDataReader(DbDataReader reader, IInstrumentationHandler instrumentationHandler) : this(reader, CommandBehavior.Default, instrumentationHandler)
 {
 }
Beispiel #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InstrumentedDbProviderFactory"/> class.
 /// A proxy provider factory
 /// </summary>
 /// <param name="factory">The provider factory to wrap.</param>
 /// <param name="instrumentationHandler"></param>
 /// <remarks>
 /// </remarks>
 public InstrumentedDbProviderFactory(DbProviderFactory factory, IInstrumentationHandler instrumentationHandler)
 {
     this._factory = factory;
     this._instrumentationHandler = instrumentationHandler;
 }