/// <summary> /// Creates a PollingFileSystemEventProducer /// </summary> /// <param name="directory">The directory to watch</param> /// <param name="channel">The channel where events should be sent</param> /// <param name="scheduler">Event scheduler</param> /// <param name="fiber">Fiber to schedule on</param> /// <param name="checkInterval">The maximal time between events or polls on a given file</param> /// <param name="checkSubDirectory">Indicates if subdirectorys will be checked or ignored</param> public PollingFileSystemEventProducer(string directory, UntypedChannel channel, [NotNull] Scheduler scheduler, Fiber fiber, TimeSpan checkInterval, bool checkSubDirectory) { if (scheduler == null) { throw new ArgumentNullException("scheduler"); } _directory = directory; _channel = channel; _fiber = fiber; _hashes = new Dictionary <string, Guid>(); _scheduler = scheduler; _checkInterval = checkInterval; _scheduledAction = scheduler.Schedule(3.Seconds(), _fiber, HashFileSystem); var myChannel = new ChannelAdapter(); _connection = myChannel.Connect(connectionConfigurator => { connectionConfigurator.AddConsumerOf <FileSystemChanged>().UsingConsumer(HandleFileSystemChangedAndCreated); connectionConfigurator.AddConsumerOf <FileSystemCreated>().UsingConsumer(HandleFileSystemChangedAndCreated); connectionConfigurator.AddConsumerOf <FileSystemRenamed>().UsingConsumer(HandleFileSystemRenamed); connectionConfigurator.AddConsumerOf <FileSystemDeleted>().UsingConsumer(HandleFileSystemDeleted); }); _fileSystemEventProducer = new FileSystemEventProducer(directory, myChannel, checkSubDirectory); }
/// <summary> /// Creates a PollingFileSystemEventProducer /// </summary> /// <param name="directory">The directory to watch</param> /// <param name="channel">The channel where events should be sent</param> /// <param name="scheduler">Event scheduler</param> /// <param name="fiber">Fiber to schedule on</param> /// <param name="checkInterval">The maximal time between events or polls on a given file</param> /// <param name="checkSubDirectory">Indicates if subdirectorys will be checked or ignored</param> public PollingFileSystemEventProducer(string directory, UntypedChannel channel, [NotNull] Scheduler scheduler, Fiber fiber, TimeSpan checkInterval, bool checkSubDirectory) { if (scheduler == null) throw new ArgumentNullException("scheduler"); _directory = directory; _channel = channel; _fiber = fiber; _hashes = new Dictionary<string, Guid>(); _scheduler = scheduler; _checkInterval = checkInterval; _scheduledAction = scheduler.Schedule(3.Seconds(), _fiber, HashFileSystem); var myChannel = new ChannelAdapter(); _connection = myChannel.Connect(connectionConfigurator => { connectionConfigurator.AddConsumerOf<FileSystemChanged>().UsingConsumer(HandleFileSystemChangedAndCreated); connectionConfigurator.AddConsumerOf<FileSystemCreated>().UsingConsumer(HandleFileSystemChangedAndCreated); connectionConfigurator.AddConsumerOf<FileSystemRenamed>().UsingConsumer(HandleFileSystemRenamed); connectionConfigurator.AddConsumerOf<FileSystemDeleted>().UsingConsumer(HandleFileSystemDeleted); }); _fileSystemEventProducer = new FileSystemEventProducer(directory, myChannel, checkSubDirectory); }