static void Main(string[] args) { Console.WriteLine("Hello World!"); IServiceCollection services = new ServiceCollection(); services .AddLogging(l => { l.AddConsole(); }) .AddSpool(); services.Configure <SpoolOptions>(options => { options.FilePools.ConfigureDefault(c => { c.Name = DefaultFilePool.Name; c.Path = "E:\\SpoolTest"; c.EnableFileWatcher = true; c.FileWatcherPath = "D:\\SpoolWatcher"; c.EnableAutoReturn = true; c.FileWatcherLastWrite = 3; c.FileWatcherSkipZeroFile = true; c.FileWatcherCopyThread = 2; c.ScanReturnFileMillSeconds = 2000; c.AutoReturnSeconds = 300; }); }); var serviceProvider = services.BuildServiceProvider(); _filePoolFactory = serviceProvider.GetService <IFilePoolFactory>(); _logger = serviceProvider.GetService <ILogger <Program> >(); var filePool = _filePoolFactory.GetOrCreate(DefaultFilePool.Name); //Run(); Console.ReadLine(); }
/// <summary> /// Get or create file pool with generic type /// </summary> /// <typeparam name="TFilePool"></typeparam> /// <param name="filePoolFactory"></param> /// <returns></returns> public static IFilePool GetOrCreate <TFilePool>(this IFilePoolFactory filePoolFactory) { return(filePoolFactory.GetOrCreate( FilePoolNameAttribute.GetFilePoolName <TFilePool>() )); }
/// <summary> /// ctor /// </summary> public FilePool(IFilePoolFactory filePoolFactory) { _filePool = filePoolFactory.GetOrCreate <TFilePool>(); }
public DefaultFilePoolTest() { _options = ServiceProvider.GetService <IOptions <SpoolOptions> >().Value; _filePoolFactory = ServiceProvider.GetService <IFilePoolFactory>(); }