Beispiel #1
0
        public void ExecuteRecipeStep(RecipeContext recipeContext)
        {
            if (!String.Equals(recipeContext.RecipeStep.Name, "ThemeSettings", StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            foreach (var themeElement in recipeContext.RecipeStep.Step.Elements())
            {
                var themeName = themeElement.Attr <string>("Name");

                foreach (var profileElement in themeElement.Elements())
                {
                    var profileName = profileElement.Attr <string>("Name");
                    var profile     = _themeSettingsService.GetProfile(profileName) ?? new ThemeProfile();

                    profile.Name        = profileElement.Attr <string>("Name");
                    profile.Description = profileElement.Attr <string>("Description");
                    profile.Theme       = themeName;
                    profile.IsCurrent   = profileElement.Attr <bool>("IsCurrent");
                    profile.Settings    = _themeSettingsService.DeserializeSettings(profileElement.Value);

                    _themeSettingsService.SaveProfile(profile);
                }
            }

            recipeContext.Executed = true;
        }
        public ActionResult Edit(int id)
        {
            var profile          = _themeSettingsService.GetProfile(id);
            var settingsManifest = _themeSettingsService.GetSettingsManifest(profile.Theme);

            var viewModel = new ProfileViewModel
            {
                Name         = profile.Name,
                Description  = profile.Description,
                Theme        = _themeSettingsService.GetTheme(profile.Theme),
                SettingsForm = _settingsFormBuilder.BuildForm(settingsManifest),
                IsCurrent    = profile.IsCurrent
            };

            _settingsFormBuilder.BindForm(viewModel.SettingsForm, new ThemeSettingsValueProvider(profile.Settings));
            return(View(viewModel));
        }
Beispiel #3
0
        public override void Execute(RecipeExecutionContext context)
        {
            foreach (var themeElement in context.RecipeStep.Step.Elements())
            {
                var themeName = themeElement.Attr <string>("Name");

                foreach (var profileElement in themeElement.Elements())
                {
                    var profileName = profileElement.Attr <string>("Name");
                    var profile     = _themeSettingsService.GetProfile(profileName) ?? new ThemeProfile();

                    profile.Name        = profileElement.Attr <string>("Name");
                    profile.Description = profileElement.Attr <string>("Description");
                    profile.Theme       = themeName;
                    profile.IsCurrent   = profileElement.Attr <bool>("IsCurrent");
                    profile.Settings    = _themeSettingsService.DeserializeSettings(profileElement.Value);

                    _themeSettingsService.SaveProfile(profile);
                }
            }
        }