/// <summary>
        /// Reads all stochastic soil models from the <paramref name="stochasticSoilModelReader"/>.
        /// </summary>
        /// <param name="stochasticSoilModelReader">The <see cref="StochasticSoilModelReader"/>.</param>
        /// <returns>Returns a <see cref="ReadResult{T}"/> collection of read stochastic soil models.</returns>
        /// <exception cref="CriticalFileReadException">Thrown when the database returned incorrect
        /// values for required properties.</exception>
        /// <exception cref="StochasticSoilModelException">Thrown when:
        /// <list type="bullet">
        /// <item>no stochastic soil profiles could be read;</item>
        /// <item>the read failure mechanism type is not supported.</item>
        /// </list>
        /// </exception>
        private ReadResult <StochasticSoilModel> GetStochasticSoilModelReadResult(StochasticSoilModelReader stochasticSoilModelReader)
        {
            int totalNumberOfSteps = stochasticSoilModelReader.StochasticSoilModelCount;
            var currentStep        = 1;

            var soilModels = new Collection <StochasticSoilModel>();

            while (stochasticSoilModelReader.HasNext)
            {
                if (Canceled)
                {
                    return(new ReadResult <StochasticSoilModel>(false));
                }

                NotifyProgress(Resources.StochasticSoilModelImporter_GetStochasticSoilModelReadResult_Reading_stochastic_soil_models_from_database,
                               currentStep++,
                               totalNumberOfSteps);
                soilModels.Add(stochasticSoilModelReader.ReadStochasticSoilModel());
            }

            return(new ReadResult <StochasticSoilModel>(false)
            {
                Items = soilModels
            });
        }
        private ReadResult <StochasticSoilModel> ReadStochasticSoilModels()
        {
            NotifyProgress(Resources.StochasticSoilModelImporter_Reading_database, 1, 1);
            try
            {
                using (var stochasticSoilModelReader = new StochasticSoilModelReader(FilePath))
                {
                    stochasticSoilModelReader.Validate();
                    return(GetStochasticSoilModelReadResult(stochasticSoilModelReader));
                }
            }
            catch (Exception e) when(e is StochasticSoilModelException ||
                                     e is CriticalFileReadException)
            {
                HandleException(e);
            }

            return(new ReadResult <StochasticSoilModel>(true));
        }