Esempio n. 1
0
        //private Thread _thread;
        //private EventWaitHandle _stopSignal;

        public RandomMutatorWindow(IProject project)
        {
            var mutator = new RandomUxMutator();

            _mainFile =
                project.Documents
                .SelectPerElement(x => new { x.FilePath, x.Root })
                .WherePerElement(x => x.Root.Name.Is("App"))
                .Select(
                    x =>
                    x.Select(y => y.FilePath.Select(z => z.ToOptional()))
                    .FirstOr(() => Observable.Return(Optional.None <AbsoluteFilePath>())))
                .Switch()
                .Replay(1)
                .RefCount();

            Observable.Interval(TimeSpan.FromSeconds(1))
            .CombineLatest(_mainFile.NotNone(), (_, f) => f)
            .ConnectWhile(_state.Is(State.Started))
            .Subscribe(
                x =>
            {
                try
                {
                    mutator.Mutate(x, 10);
                }
                catch (Exception)
                {
                    // ignored
                }
            });
        }