/// <summary>
        /// Initializes the underlying connection to the data source.  Callers can
        /// optionally pass a data source connection string or other key in the
        /// <paramref name="connectionString" /> parameter.
        /// </summary>
        /// <param name="connectionString">
        /// String containing information to be utilized in
        /// making a connection to the specific data source needed.
        /// </param>
        /// <remarks>
        /// If the <paramref name="connectionString" /> parameter is an empty string
        /// or whitespace, then the default connection to the data source, as configured
        /// in App.config, is utilized.  Otherwise, the connection string passed is
        /// sent to the underlying unit-of-work object.
        /// </remarks>
        // ReSharper disable once MemberCanBeProtected.Global
        public virtual void DoInitialize(
            IEmployeesUnitOfWork unitOfWorkObject)
        {
            CleanupUnitOfWork();

            UnitOfWork = unitOfWorkObject;
        }
        /// <summary>
        /// Initializes all data services using the connection to the underlying data source provided by the unit-of-work object referenced by <paramref name="unitOfWorkObject" />.
        /// </summary>
        /// <param name="unitOfWorkObject">
        /// Reference to an instance of an object that implements
        /// <see
        ///     cref="T:EmployeeManager.BusinessLayer.IEmployeesUnitOfWork" />
        /// having the proper connection to the underlying data source.
        /// </param>
        /// <param name="exceptionRaisedEventHandler">
        /// (Optional.) If specified, reference to a method that serves as a handler for
        /// exceptions raised by any one of the services.
        /// </param>
        public void InitializeAll(IEmployeesUnitOfWork unitOfWorkObject,
                                  Action <Exception> exceptionRaisedEventHandler = null)
        {
            EmployeeTypeService.Instance.DoInitialize(unitOfWorkObject);
            EmployeeService.Instance.DoInitialize(unitOfWorkObject);

            InstallExceptionRaisedEventHandler(exceptionRaisedEventHandler);
        }
        /// <summary>
        /// Initializes the underlying connection to the data source.  Callers can
        /// optionally pass a data source connection string or other key in the
        /// <paramref name="connectionString" /> parameter.
        /// </summary>
        /// <param name="connectionString">
        /// String containing information to be utilized in
        /// making a connection to the specific data source needed.
        /// </param>
        /// <remarks>
        /// If the <paramref name="connectionString" /> parameter is an empty string
        /// or whitespace, then the default connection to the data source, as configured
        /// in App.config, is utilized.  Otherwise, the connection string passed is
        /// sent to the underlying unit-of-work object.
        /// </remarks>
        // ReSharper disable once MemberCanBeProtected.Global
        public virtual void DoInitialize(
            string connectionString = "")
        {
            CleanupUnitOfWork();

            UnitOfWork = string.IsNullOrWhiteSpace(connectionString)
                ? new EmployeesUnitOfWork()
                : new EmployeesUnitOfWork(connectionString);
        }
 /// <summary>
 /// Performs cleanup of the underlying unit-of-work object.
 /// </summary>
 private void CleanupUnitOfWork()
 {
     UnitOfWork?.Dispose();
     UnitOfWork = null;
 }