public ProjectMutator(MutatingEngine <MutatingContext <ProjectFile> > engine, ProjectFileWorkspace workspace)
        {
            _engine    = engine;
            _workspace = workspace;

            NewProject = engine.EventSource(mc => new AddProject(mc.GetChange <NewProjectChange>().Project),
                                            context => context.Change is NewProjectChange);
            RemovedProject = engine.EventSource(mc => new RemoveProject(mc.GetChange <RemoveProjectChange>().Project),
                                                context => context.Change is RemoveProjectChange);
            NewLanguage = engine.EventSource(mc => mc.GetChange <LanguageChange>().ToEventData(),
                                             context => context.Change is LanguageChange);
            NewImport = engine.EventSource(mc => mc.GetChange <AddImportChange>().ToEventData(),
                                           context => context.Change is AddImportChange);
            RemoveImport = engine.EventSource(mc => mc.GetChange <RemoveImportChange>().ToData(),
                                              context => context.Change is RemoveImportChange);

            NewLanguage.RespondOn(null, newLang =>
            {
                if (workspace.ProjectFile.GlobalLanguages.Contains(newLang.ActiveLanguage))
                {
                    return;
                }

                if (!Projects.All(p => p.ActiveLanguages.Contains(newLang.ActiveLanguage)))
                {
                    return;
                }

                _engine.Mutate(nameof(AddLanguage) + "Global-Single",
                               obs => obs.Select(context => context.Update(new GlobalLanguageChange(newLang.ActiveLanguage),
                                                                           context.Data with
                {
                    GlobalLanguages = context.Data.GlobalLanguages.Add(newLang.ActiveLanguage)
                })));
            });
Ejemplo n.º 2
0
 public BuildMutator(MutatingEngine <MutatingContext <ProjectFile> > engine)
 {
     _engine   = engine;
     Intigrate = engine.EventSource(mc => mc.GetChange <IntigrateImportChange>().ToEvent(),
                                    mc => mc.Change is IntigrateImportChange);
     ProjectPath = engine.EventSource(mc => mc.GetChange <ProjectPathChange>().ToEventData(),
                                      context => context.Change is ProjectPathChange);
 }
Ejemplo n.º 3
0
 public SourceMutator(MutatingEngine <MutatingContext <ProjectFile> > engine, ProjectFileWorkspace workspace)
 {
     _engine      = engine;
     _workspace   = workspace;
     SaveRequest  = engine.EventSource(mc => new SaveRequest(_workspace.ProjectFile), context => !(context.Change is ResetChange));
     ProjectReset = engine.EventSource(mc => new ProjectRest(_workspace.ProjectFile), context => context.Change is ResetChange);
     SourceUpdate = engine.EventSource(mc => new SourceUpdated(mc.Data.Source), context => context.Change is SourceChange);
 }
Ejemplo n.º 4
0
        public EntryMutator(MutatingEngine <MutatingContext <ProjectFile> > engine)
        {
            _engine = engine;

            EntryRemove = engine.EventSource(context => new EntryRemove(context.GetChange <RemoveEntryChange>().Entry),
                                             context => context.Change is RemoveEntryChange);
            EntryUpdate = engine.EventSource(context => new EntryUpdate(context.GetChange <EntryChange>().Entry),
                                             context => context.Change is EntryChange);
            EntryAdd = engine.EventSource(context => context.GetChange <NewEntryChange>().ToData(),
                                          context => context.Change is NewEntryChange);
        }
        public EntryMutator(MutatingEngine <MutatingContext <ProjectFile> > engine)
        {
            _engine = engine;

            EntryRemove = engine.EventSource(c => c.Select(cc => new EntryRemove(cc.GetChange <RemoveEntryChange>().Entry)),
                                             c => from constext in c
                                             from change in constext.Change
                                             select change is RemoveEntryChange);

            EntryUpdate = engine.EventSource(c => c.Select(cc => new EntryUpdate(cc.GetChange <EntryChange>().Entry)),
                                             c => from context in c
                                             from change in context.Change
                                             select change is EntryChange);

            EntryAdd = engine.EventSource(c => c.Select(cc => cc.GetChange <NewEntryChange>().ToData()),
                                          c => from context in c
                                          from change in context.Change
                                          select change is NewEntryChange);
        }
Ejemplo n.º 6
0
        public ProjectMutator(MutatingEngine <MutatingContext <ProjectFile> > engine, ProjectFileWorkspace workspace)
        {
            _engine    = engine;
            _workspace = workspace;

            NewProject = engine.EventSource(
                c => c.Select(mc => new AddProject(mc.GetChange <NewProjectChange>().Project)),
                c => from context in c
                from change in context.Change
                select change is NewProjectChange);

            RemovedProject = engine.EventSource(c => c.Select(mc => new RemoveProject(mc.GetChange <RemoveProjectChange>().Project)),
                                                c => from context in c
                                                from change in context.Change
                                                select change is RemoveProjectChange);

            NewLanguage = engine.EventSource(c => c.Select(mc => mc.GetChange <LanguageChange>().ToEventData()),
                                             c => from context in c
                                             from change in context.Change
                                             select change is LanguageChange);

            NewImport = engine.EventSource(c => c.Select(mc => mc.GetChange <AddImportChange>().ToEventData()),
                                           c => from context in c
                                           from change in context.Change
                                           select change is AddImportChange);

            RemoveImport = engine.EventSource(c => c.Select(mc => mc.GetChange <RemoveImportChange>().ToData()),
                                              c => from context in c
                                              from change in context.Change
                                              select change is RemoveImportChange);

            NewLanguage.RespondOn(null, mayNewLang =>
                                  Do(from newlang in mayNewLang
                                     where !workspace.ProjectFile.GlobalLanguages.Contains(newlang.ActiveLanguage)
                                     where Projects.All(p => p.ActiveLanguages.Contains(newlang.ActiveLanguage))
                                     select Action(() => _engine.Mutate(nameof(AddLanguage) + "Global-Single",
                                                                        c => from context in c
                                                                        select context.WithChange(new GlobalLanguageChange(newlang.ActiveLanguage))))));
        }