static void Main(string[] args) { DisplayHeader(); IKernel kernel = new StandardKernel(); kernel.Load(Assembly.GetExecutingAssembly()); IFileReader fileReader = kernel.Get<IFileReader>(); var unitOfWork = new UnitOfWork<FileWatcherContext>(); // set up your basic configurations here var settings = new ConfigurationSetting { Path = @"C:\Users\Nino\Desktop\test", // set this to the folder that you would like to monitor RaiseEvent = true, Extention = "*.xml" // extention of a file the needs to be monitored }; // call the service IMainFileWatcher watcher = new MainFileWatcher(fileReader, unitOfWork); // pass the config watcher.SetConfiguration(settings); Console.Read(); }
/// <summary> /// Sets the configuration. /// </summary> /// <param name="setting">The setting.</param> public void SetConfiguration(ConfigurationSetting setting) { if (setting == null) { throw new ArgumentNullException("setting"); } _fileSystemWatcher.Path = setting.Path; _fileSystemWatcher.EnableRaisingEvents = setting.RaiseEvent; _fileSystemWatcher.Filter = setting.Extention; _fileSystemWatcher.Created += new FileSystemEventHandler(OnCreated); _fileSystemWatcher.Changed += new FileSystemEventHandler(OnChanged); _fileSystemWatcher.Deleted += new FileSystemEventHandler(OnDeleted); _fileSystemWatcher.Renamed += new RenamedEventHandler(OnRenamed); }