Exemplo n.º 1
0
        private static UcfmConfigSettings EnsureConfig()
        {
            var settingsFile = HttpRuntime.Cache["umbracoCloudFlareManagerSettingsFile"];
            var fullPath = HostingEnvironment.MapPath(PluginFolder + "/" + ConfigFileName);

            if (settingsFile != null) return (UcfmConfigSettings)settingsFile;

            var temp = new UcfmConfigSettings { CloudFlareEmail = string.Empty, CloudFlareApiKey = string.Empty};
            if (fullPath == null) return temp;

            try
            {
                var configFile = HostingEnvironment.MapPath(string.Format("{0}/{1}", PluginFolder, ConfigFileName));
                var serializer = new XmlSerializer(typeof(UcfmConfigSettings));

                using (var fs = new FileStream(configFile, FileMode.Open))
                {
                    temp = (UcfmConfigSettings)serializer.Deserialize(fs);
                    HttpRuntime.Cache.Insert("umbracoCloudFlareManagerSettingsFile", temp, new CacheDependency(fullPath));
                }
            }
            catch (Exception ex)
            {
                LogHelper.Warn<Config>("Unable to load the settings: {0}", () => ex);
            }

            return temp;
        }
Exemplo n.º 2
0
        public static void SaveSettings(UcfmConfigSettings settings)
        {
            var configFile = HostingEnvironment.MapPath(string.Format("{0}/{1}", PluginFolder, ConfigFileName));
            if (configFile == null) return;

            if (File.Exists(configFile))
                File.Delete(configFile);

            var serializer = new XmlSerializer(typeof(UcfmConfigSettings));
            using (var w = new StreamWriter(configFile))
            {
                serializer.Serialize(w, settings);
            }

            HttpRuntime.Cache.Remove("umbracoCloudFlareManagerSettingsFile");
            EnsureConfig();
        }
 public void SaveSettings(UcfmConfigSettings settings)
 {
     Config.SaveSettings(settings);
 }