public override ICommand AddChartTemplateCommand(CurveChartTemplate template, IWithChartTemplates withChartTemplates)
        {
            if (withChartTemplates.IsAnImplementationOf <IMoBiSimulation>())
            {
                return(new AddChartTemplateToSimulationSettingsCommand(template, withChartTemplates.DowncastTo <IMoBiSimulation>()).Run(_context));
            }

            return(updateChartTemplates(withChartTemplates, x => x.AddChartTemplate(template)));
        }
        protected override ICommand ReplaceTemplatesCommand(IWithChartTemplates withChartTemplates, IEnumerable <CurveChartTemplate> curveChartTemplates)
        {
            if (withChartTemplates.IsAnImplementationOf <IMoBiSimulation>())
            {
                return(new ReplaceSimulationTemplatesCommand(withChartTemplates.DowncastTo <IMoBiSimulation>(), curveChartTemplates).Run(_context));
            }

            return(updateChartTemplates(withChartTemplates, x =>
            {
                withChartTemplates.RemoveAllChartTemplates();
                curveChartTemplates.Each(withChartTemplates.AddChartTemplate);
            }));
        }
        public override ICommand UpdateChartTemplateCommand(CurveChartTemplate curveChartTemplate, IWithChartTemplates withChartTemplates, string templateName)
        {
            if (withChartTemplates.IsAnImplementationOf <IMoBiSimulation>())
            {
                return(new UpdateChartTemplateInSimulationSettingsCommand(curveChartTemplate, withChartTemplates.DowncastTo <IMoBiSimulation>(), templateName).Run(_context));
            }

            return(updateChartTemplates(withChartTemplates, x =>
            {
                withChartTemplates.RemoveChartTemplate(templateName);
                curveChartTemplate.Name = templateName;
                withChartTemplates.AddChartTemplate(curveChartTemplate);
            }));
        }