Пример #1
0
        /// <summary>
        ///     Loads the entities and produces a load result.
        /// </summary>
        public ILoaderState Load()
        {
            ILoaderLogWriter log = Log ?? new LoaderLogWriter(_logger);

            try
            {
                var dataSourceProcessor = new DataSourceProcessor <TDtoIn, TLoadStateData>(_validator, log)
                {
                    EntitiesGet  = GetDtos(),
                    Initialize   = Initialize,
                    MaxBatchSize = MaxBatchSize,
                    Processor    = (loaderState, dtoIn) => Process(dtoIn, loaderState),
                    Commit       = Commit
                };

                ILoaderState result = dataSourceProcessor.Process();

                return(result);
            }
            finally
            {
                OnLoaded();
            }
        }
        /// <summary>
        ///     Creates a new instance.
        /// </summary>
        /// <param name="validator">
        ///     Optional validator to use. Null will use 'SpecProvider'
        /// </param>
        /// <param name="log">The log to post event to.</param>
        public DataSourceProcessor(IProvideSpecifications <TEntityDtoIn> validator = null, ILoaderLogWriter log = null)
        {
            _validator = validator ?? new SpecProvider <TEntityDtoIn>();

            Log = Log ?? new LoaderLogWriter(LogManager.GetLogger(GetLogSystemName()));
        }