Beispiel #1
0
        internal Swatcher(ISwatcherConfig config, IWindowsFacade windowsFacade)
        {
            Config        = config;
            WindowsFacade = windowsFacade;

            var createdEventStream         = CreateCreatedEventStream();
            var finishedCreatedEventStream = CreateFinishedCreatedEventStream(createdEventStream);

            finishedCreatedEventStream
            .Delay(TimeSpan.FromSeconds(2.5))
            .Subscribe(x => CreatedEventsInProgress.Remove(x.FullPath));

            var createdEventWindows         = CreateCreatedEventWindowStream(createdEventStream);
            var finishedCreatedEventWindows = CreateFinishedCreatedEventWindows(finishedCreatedEventStream);

            var changedEventStream  = CreateChangedEventStream();
            var changedEventWindows = CreatedChangedEventWindows(changedEventStream);

            Renamed = CreatePublicRenamedStream(Config);
            Deleted = CreatePublicDeletedStream();
            Created = CreatePublicCreatedStream(finishedCreatedEventStream);
            Changed = CreatePublicChangedStream(changedEventStream,
                                                changedEventWindows, createdEventWindows, finishedCreatedEventWindows);

            ChangedEventPatternSource =
                Changed.Select(x => new EventPattern <SwatcherEventArgs>(this, x)).ToEventPattern();
            ChangedEventPatternSource.OnNext += OnItemChanged;

            DeletedEventPatternSource =
                Deleted.Select(x => new EventPattern <SwatcherEventArgs>(this, x)).ToEventPattern();
            DeletedEventPatternSource.OnNext += OnItemDeleted;

            CreatedEventPatternSource =
                Created.Select(x => new EventPattern <SwatcherCreatedEventArgs>(this, x)).ToEventPattern();
            CreatedEventPatternSource.OnNext += OnItemCreated;

            RenamedEventPatternSource =
                Renamed.Select(x => new EventPattern <SwatcherRenamedEventArgs>(this, x)).ToEventPattern();
            RenamedEventPatternSource.OnNext += OnItemRenamed;
        }