//------------------------------------------------------------------------------ // // Method: MicrosoftAccessMetricLoggerImplementation (constructor) // //------------------------------------------------------------------------------ /// <summary> /// Initialises a new instance of the ApplicationMetrics.MicrosoftAccessMetricLoggerImplementation class. Note this is an additional constructor to facilitate unit tests, and should not be used to instantiate the class under normal conditions. /// </summary> /// <param name="databaseFilePath">The full path to the Microsoft Access data file.</param> /// <param name="metricCategoryName">The name of the category which the metric events should be logged under in the database.</param> /// <param name="bufferProcessingStrategy">Object which implements a processing strategy for the buffers (queues).</param> /// <param name="intervalMetricChecking">Specifies whether an exception should be thrown if the correct order of interval metric logging is not followed (e.g. End() method called before Begin()).</param> /// <param name="dbConnection">A test (mock) database connection object.</param> /// <param name="dbCommand">A test (mock) database command object.</param> /// <param name="dateTime">A test (mock) DateTime object.</param> /// <param name="exceptionHandler">A test (mock) exception handler object.</param> public MicrosoftAccessMetricLoggerImplementation(string databaseFilePath, string metricCategoryName, IBufferProcessingStrategy bufferProcessingStrategy, bool intervalMetricChecking, IOleDbConnection dbConnection, IOleDbCommand dbCommand, IDateTime dateTime, IExceptionHandler exceptionHandler) : base(bufferProcessingStrategy, intervalMetricChecking, dateTime, exceptionHandler) { InitialisePrivateMembers(databaseFilePath, metricCategoryName); this.dbConnection = dbConnection; this.dbCommand = dbCommand; }
//------------------------------------------------------------------------------ // // Method: MicrosoftAccessMetricLoggerImplementation (constructor) // //------------------------------------------------------------------------------ /// <summary> /// Initialises a new instance of the ApplicationMetrics.MicrosoftAccessMetricLoggerImplementation class. /// </summary> /// <param name="databaseFilePath">The full path to the Microsoft Access data file.</param> /// <param name="metricCategoryName">The name of the category which the metric events should be logged under in the database.</param> /// <param name="bufferProcessingStrategy">Object which implements a processing strategy for the buffers (queues).</param> /// <param name="intervalMetricChecking">Specifies whether an exception should be thrown if the correct order of interval metric logging is not followed (e.g. End() method called before Begin()).</param> public MicrosoftAccessMetricLoggerImplementation(string databaseFilePath, string metricCategoryName, IBufferProcessingStrategy bufferProcessingStrategy, bool intervalMetricChecking) : base(bufferProcessingStrategy, intervalMetricChecking) { InitialisePrivateMembers(databaseFilePath, metricCategoryName); dbConnection = new OleDbConnection(); // Need to cast the connection to an OleDbConnection in order to get the underlying connection // Usually would avoid casting, but in this case it should be safe, as the member was just set to this object type on the previous line dbCommand = new OleDbCommand("", ((OleDbConnection)dbConnection).Connection); }
//------------------------------------------------------------------------------ // // Method: MicrosoftAccessMetricLogger (constructor) // //------------------------------------------------------------------------------ /// <summary> /// Initialises a new instance of the ApplicationMetrics.MicrosoftAccessMetricLogger class. Note this is an additional constructor to facilitate unit tests, and should not be used to instantiate the class under normal conditions. /// </summary> /// <param name="databaseFilePath">The full path to the Microsoft Access data file.</param> /// <param name="metricCategoryName">The name of the category which the metric events should be logged under in the database.</param> /// <param name="bufferProcessingStrategy">Object which implements a processing strategy for the buffers (queues).</param> /// <param name="intervalMetricChecking">Specifies whether an exception should be thrown if the correct order of interval metric logging is not followed (e.g. End() method called before Begin()).</param> /// <param name="dbConnection">A test (mock) database connection object.</param> /// <param name="dbCommand">A test (mock) database command object.</param> /// <param name="dateTime">A test (mock) DateTime object.</param> /// <param name="exceptionHandler">A test (mock) exception handler object.</param> public MicrosoftAccessMetricLogger(string databaseFilePath, string metricCategoryName, IBufferProcessingStrategy bufferProcessingStrategy, bool intervalMetricChecking, IOleDbConnection dbConnection, IOleDbCommand dbCommand, IDateTime dateTime, IExceptionHandler exceptionHandler) { loggerImplementation = new MicrosoftAccessMetricLoggerImplementation(databaseFilePath, metricCategoryName, bufferProcessingStrategy, intervalMetricChecking, dbConnection, dbCommand, dateTime, exceptionHandler); }