Esempio n. 1
0
 public SftpInitializer(
     ILogger <SftpInitializer> logger,
     ISftpClientFactory sftpClientFactory,
     SftpClientOptions sftpClientOptions)
 {
     _logger            = logger ?? throw new ArgumentNullException(nameof(logger));
     _sftpClientFactory = sftpClientFactory ?? throw new ArgumentNullException(nameof(sftpClientFactory));
     _sftpClientOptions = sftpClientOptions ?? throw new ArgumentNullException(nameof(sftpClientOptions));
     _sftpClientOptions.AssertValid();
 }
Esempio n. 2
0
        public SftpClientFactory(
            SftpClientOptions options,
            ITempFileStreamFactory tempFileStreamFactory,
            ILoggerFactory loggerFactory)
        {
            _options = options ?? throw new ArgumentNullException(nameof(options));
            _options.AssertValid();

            _tempFileStreamFactory = tempFileStreamFactory ?? throw new ArgumentNullException(nameof(tempFileStreamFactory));
            _loggerFactory         = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));
        }
Esempio n. 3
0
        /// <summary>
        /// Adds to SSH.NET SFTP services.
        /// </summary>
        public static IServiceCollection AddSftpServices(
            this IServiceCollection services,
            SftpClientOptions sftpClientOptions)
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }
            if (sftpClientOptions == null)
            {
                throw new ArgumentNullException(nameof(sftpClientOptions));
            }

            sftpClientOptions.AssertValid();

            services.TryAddSingleton(sftpClientOptions);
            services.TryAddSingleton <ISftpClientFactory, SftpClientFactory>();
            services.AddAppInitializer <SftpInitializer>();

            return(services);
        }