示例#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);
         }
     }
 }
示例#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));
            }
        }
示例#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;
     }
 }
示例#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);
     }
 }
示例#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);
            }
        }
示例#6
0
        public string GetSetting(string name)
        {
            IStringProperty property = ClientSettingsView.SettingToProperty(this.GetSettingInternal(name));

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