public GetSortedFoldersQueryHandler(IFileProviderFactory fileProviderFactory, IMemoryCache memoryCache) { Guard.IsNotNull(fileProviderFactory, nameof(fileProviderFactory)); Guard.IsNotNull(memoryCache, nameof(memoryCache)); _fileProviderFactory = fileProviderFactory; _memoryCache = memoryCache; }
/// <summary> /// Initializes a new instance of the <see cref="FtpServer"/> class. /// The server uses custom file, data connection, and authentication provider. /// </summary> /// <param name="endPoint">The local end point to listen, usually 0.0.0.0:21.</param> /// <param name="fileProviderFactory">The <see cref="IFileProviderFactory"/> to use.</param> /// <param name="dataConnFactory">The <see cref="IDataConnectionFactory"/> to use.</param> /// <param name="authenticator">The <see cref="IAuthenticator"/> to use.</param> public FtpServer( IPEndPoint endPoint, IFileProviderFactory fileProviderFactory, IDataConnectionFactory dataConnFactory, IAuthenticator authenticator) : this(endPoint, fileProviderFactory, dataConnFactory, authenticator, null) { }
/// <summary> /// Initializes a new instance of the <see cref="FtpServer"/> class /// with <see cref="SimpleFileProviderFactory"/>, <see cref="LocalDataConnectionFactory"/>, /// and <see cref="AnonymousAuthenticator"/>. /// </summary> /// <param name="endPoint">The local end point to listen, usually 0.0.0.0:21</param> /// <param name="baseDirectory">The directory to provide files</param> public FtpServer(IPEndPoint endPoint, string baseDirectory) { this.endPoint = endPoint; tcpListener = new TcpListener(endPoint); fileProviderFactory = new SimpleFileProviderFactory(baseDirectory); dataConnFactory = new LocalDataConnectionFactory(); authenticator = new AnonymousAuthenticator(); }
/// <summary> /// Creates a new <see cref="IFileProvider" /> from the file system. /// </summary> /// <param name="fileSystem">The file system.</param> /// <param name="fileProvider">When this method returns, contains an <see cref="IFileProvider"/> created from the file system.</param> /// <returns> /// <c>true</c> if the <see cref="IFileProvider" /> was successfully created; otherwise, <c>false</c>. /// </returns> public static bool TryCreateFileProvider(this IFileSystem fileSystem, [MaybeNullWhen(false)] out IFileProvider fileProvider) { fileProvider = fileSystem switch { IFileProviderFactory fileProviderFactory => fileProviderFactory.Create(), _ => null }; return(fileProvider != null); } }
private static void Validate(IFileProviderFactory fileProviderFactory, GetSortedFoldersDefinition parameters) { if (parameters.Limit < 0) { throw new ValidationPublicException("Negative value can't be used for a limit"); } if (!fileProviderFactory.Exists(parameters.Path)) { throw new ObjectNotFoundPublicException("Path not found"); } }
public FileService( IFileRepository repository, IFileProviderFactory fileProvider, IRepository <FieldEntity> fieldRepository, IMapper mapper, ITime time) { _repository = repository; _fieldsRepository = fieldRepository; _fileProvider = fileProvider; _time = time; _mapper = mapper; }
public CFTReadAllProcess( IOptions <FileScanerOptions> options, IFileProviderFactory fileProviderFactory, IServiceProvider applicationServices, ICFTMiddlewareBuilder cftMiddlewareBuilder) { if (fileProviderFactory == null) { throw new ArgumentNullException(nameof(fileProviderFactory)); } _options = options?.Value ?? throw new ArgumentNullException(nameof(options)); _applicationServices = applicationServices ?? throw new ArgumentNullException(nameof(applicationServices)); _fileProvider = fileProviderFactory.GetFileProvider(options.Value.FileProviderType, options.Value.FileProviderSettings); _semaphore = new SemaphoreSlim(_options.NumberParallelFileWork, _options.NumberParallelFileWork); }
public CommandsFactory(IMovieTheaterDbContext movieDbContext, IStaffDbContext staffDbContext, IShopDbContext shopDbContext, IModelsFactory factory, IExporter exporter, IFileProviderFactory fileProviderFactory) { Guard.WhenArgument(movieDbContext, DbContextCheck).IsNull().Throw(); Guard.WhenArgument(factory, ModelsFactoryCheck).IsNull().Throw(); Guard.WhenArgument(exporter, ExporterCheck).IsNull().Throw(); Guard.WhenArgument(fileProviderFactory, FileProviderFactoryCheck).IsNull().Throw(); this.moviesDbContext = movieDbContext; this.modelsFactory = factory; this.staffDbContext = staffDbContext; this.shopDbContext = shopDbContext; this.exporter = exporter; this.fileProviderFactory = fileProviderFactory; }
/// <summary> /// Initializes a new instance of the <see cref="FtpServer"/> class. /// The server uses custom file, data connection, and authentication provider. /// </summary> /// <param name="endPoint">The local end point to listen, usually 0.0.0.0:21</param> /// <param name="fileProviderFactory">The <see cref="IFileProviderFactory"/> to use</param> /// <param name="dataConnFactory">The <see cref="IDataConnectionFactory"/> to use</param> /// <param name="authenticator">The <see cref="IAuthenticator"/> to use</param> public FtpServer( IPEndPoint endPoint, IFileProviderFactory fileProviderFactory, IDataConnectionFactory dataConnFactory, IAuthenticator authenticator) { this.endPoint = endPoint; tcpListener = new TcpListener(endPoint); this.fileProviderFactory = fileProviderFactory; this.dataConnFactory = dataConnFactory; this.authenticator = authenticator; tracer.CommandInvoked += Tracer_CommandInvoked; tracer.ReplyInvoked += Tracer_ReplyInvoked; }
public RemoveFileMiddleWare( MiddlewareDelegate <CFTFileContext> next, ILogger <RemoveFileMiddleWare> logger, IFileProviderFactory fileProviderFactory, RemoveFileOptions options) : base(next, logger) { try { options.ValidationParams(); _fileProvider = fileProviderFactory.GetFileProvider(options.FileProviderType, options.FileProviderSettings); } catch (Exception e) { throw new CFTConfigurationException("Ошибка при конфигурации модуля проверки по XSD схеме.", e); } _option = options; }
public ExportFileMiddleWare( MiddlewareDelegate <CFTFileContext> next, ILogger <ExportFileMiddleWare> logger, IFileProviderFactory fileProviderFactory, ExportFileOptions options) : base(next, logger) { try { options.ValidationParams(); _fileProvider = fileProviderFactory.GetFileProvider(options.FileProviderType, options.FileProviderSettings); var exportFolder = _fileProvider.GetDirectoryContents(options.Path); if (!exportFolder.Exists) { throw new ArgumentException($"Каталог '{options.Path}' не существует.", nameof(options.Path)); } } catch (Exception e) { throw new CFTConfigurationException("Ошибка при конфигурации модуля экспорта файла.", e); } _option = options; }
public FileScanerHostedService( ICFTReadAllProcess readAllProcess, IOptions <FileScanerOptions> options, IFileProviderFactory fileProviderFactory, ICFTMiddlewareBuilder cftMiddlewareBuilder) { if (fileProviderFactory == null) { throw new ArgumentNullException(nameof(fileProviderFactory)); } _readAllProcess = readAllProcess ?? throw new ArgumentNullException(nameof(readAllProcess)); _options = options?.Value ?? throw new ArgumentNullException(nameof(options)); _cftMiddlewareBuilder = cftMiddlewareBuilder ?? throw new ArgumentNullException(nameof(cftMiddlewareBuilder)); _fileProvider = fileProviderFactory.GetFileProvider(options.Value.FileProviderType, options.Value.FileProviderSettings); try { options.Value.ValidateOptions(); } catch (Exception e) { throw new CFTConfigurationException("Ошибка конфигурации службы.", e); } }
public CreateJsonReaderCommand(IFileProviderFactory fileProviderFactory, IMovieTheaterDbContext dbContext, IModelsFactory modelsFactory) : base(dbContext, modelsFactory) { this.fileProviderFactory = fileProviderFactory; }
private static FolderInfo[] GetFolderInfosInternal(GetSortedFoldersDefinition parameters, IFileProviderFactory fileProviderFactory, CancellationToken cancellationToken) { var fileProvider = fileProviderFactory.GetFileProvider(parameters.Path); var rootContents = fileProvider.GetDirectoryContents(string.Empty); var topDirs = rootContents.Where(fi => fi.IsDirectory); var resultList = new List <FolderInfo>(); foreach (var topDir in topDirs) { var size = GetFolderSize(fileProvider, topDir, cancellationToken); var folderInfo = new FolderInfo { Name = topDir.Name, Size = size }; resultList.Add(folderInfo); } var orderedFolders = resultList.OrderByDescending(f => f.Size); var result = parameters.Limit.HasValue ? orderedFolders.Take(parameters.Limit.Value) : orderedFolders; return(result.ToArray()); }