Пример #1
0
        public RosterService(ILoggerFacade logger)
        {
            this.Logger            = logger;
            this.DataFileDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "LaJust");
            Directory.CreateDirectory(this.DataFileDirectory);

            this.fileWatcherService                     = new DelayedFileSystemWatcher(this.DataFileDirectory);
            this.fileWatcherService.Filter              = CompetitorFileName;
            this.fileWatcherService.NotifyFilter        = NotifyFilters.CreationTime | NotifyFilters.LastWrite | NotifyFilters.FileName;
            this.fileWatcherService.Changed            += (s, e) => this.LoadCompetitors();
            this.fileWatcherService.EnableRaisingEvents = true;

            this.LoadCompetitors();
            this.competitors.CollectionChanged += (s, e) =>
            {
                if (e.Action != NotifyCollectionChangedAction.Reset)
                {
                    this.SaveCompetitors();
                }
            };
        }
Пример #2
0
        public RosterService(ILoggerFacade logger)
        {
            this.Logger = logger;
            this.DataFileDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "LaJust");
            Directory.CreateDirectory(this.DataFileDirectory);

            this.fileWatcherService = new DelayedFileSystemWatcher(this.DataFileDirectory);
            this.fileWatcherService.Filter = CompetitorFileName;
            this.fileWatcherService.NotifyFilter = NotifyFilters.CreationTime | NotifyFilters.LastWrite | NotifyFilters.FileName;
            this.fileWatcherService.Changed += (s, e) => this.LoadCompetitors();
            this.fileWatcherService.EnableRaisingEvents = true;

            this.LoadCompetitors();
            this.competitors.CollectionChanged += (s, e) =>
                {
                    if (e.Action != NotifyCollectionChangedAction.Reset)
                    {
                        this.SaveCompetitors();
                    }
                };
        }