Ejemplo n.º 1
0
 private void AddViews(params SettingsLocation[] locations)
 {
     foreach (SettingsLocation location in locations)
     {
         IClientSettingsView view = ClientSettingsView.Create(SettingsSection, location, _configurationManager, _fileService);
         if (view != null)
         {
             _settingsViews.Add(location, ClientSettingsView.Create(SettingsSection, location, _configurationManager, _fileService));
             _locationPriority.Add(location);
         }
     }
 }
Ejemplo n.º 2
0
        private ClientSetting SettingToClientSetting(SettingElement setting)
        {
            IStringProperty property = ClientSettingsView.SettingToProperty(setting);

            if (property == null)
            {
                Debug.Fail("Shouldn't be converting a null element to a ClientSetting.");
                return(null);
            }
            else
            {
                return(new ClientSetting(property.Name, property.Value, this.SettingsLocation));
            }
        }
Ejemplo n.º 3
0
 public static IClientSettingsView Create(string settingsSection, SettingsLocation settingsLocation, IConfigurationManager configurationManager, IFileService fileService)
 {
     try
     {
         ClientSettingsView view = new ClientSettingsView(settingsSection, settingsLocation, configurationManager, fileService);
         if (!view.Initialize())
         {
             return null;
         }
         return view;
     }
     catch (Exception e)
     {
         // We don't have rights most likely, go ahead and return null
         Debug.WriteLine("Could not create settings for '{0}': {1}", settingsLocation, e.Message);
         return null;
     }
 }
Ejemplo n.º 4
0
 public static IClientSettingsView Create(string settingsSection, SettingsLocation settingsLocation, IConfigurationManager configurationManager, IFileService fileService)
 {
     try
     {
         ClientSettingsView view = new ClientSettingsView(settingsSection, settingsLocation, configurationManager, fileService);
         if (!view.Initialize())
         {
             return(null);
         }
         return(view);
     }
     catch (Exception e)
     {
         // We don't have rights most likely, go ahead and return null
         Debug.WriteLine("Could not create settings for '{0}': {1}", settingsLocation, e.Message);
         return(null);
     }
 }
Ejemplo n.º 5
0
        public bool SaveSetting(string name, string value)
        {
            try
            {
                SettingElement element  = this.GetSettingInternal(name);
                XmlNode        valueXml = ClientSettingsView.SerializeToXmlElement(value);
                if (element == null)
                {
                    element = new SettingElement(name, SettingsSerializeAs.String);
                    this.clientSettings.Settings.Add(element);
                }

                element.Value.ValueXml = ClientSettingsView.SerializeToXmlElement(value);
                this.configuration.Save();
                return(true);
            }
            catch (Exception e)
            {
                // We don't have rights most likely, go ahead and fail gracefully
                Debug.WriteLine("Could not save setting for '{0}': {1}", this.SettingsLocation, e.Message);
                return(false);
            }
        }
Ejemplo n.º 6
0
        public string GetSetting(string name)
        {
            IStringProperty property = ClientSettingsView.SettingToProperty(this.GetSettingInternal(name));

            return(property == null ? null : property.Value);
        }