16 private bool _IsSynchronized;
24 public virtual object this[
string propertyName]
32 return GetPropertyValueByName(propertyName);
35 return GetPropertyValueByName(propertyName);
43 SetPropertyValueByName(propertyName, value);
48 SetPropertyValueByName(propertyName, value);
77 return _IsSynchronized;
87 private object GetPropertyValueByName(
string propertyName)
93 SettingsProperty settingsProperty =
Properties[propertyName];
94 if (settingsProperty ==
null)
96 throw new SettingsPropertyNotFoundException(
System.
SR.GetString(
"SettingsPropertyNotFound", propertyName));
98 SettingsPropertyValue settingsPropertyValue = _PropertyValues[propertyName];
99 if (settingsPropertyValue ==
null)
101 GetPropertiesFromProvider(settingsProperty.Provider);
102 settingsPropertyValue = _PropertyValues[propertyName];
103 if (settingsPropertyValue ==
null)
105 throw new SettingsPropertyNotFoundException(
System.
SR.GetString(
"SettingsPropertyNotFound", propertyName));
108 return settingsPropertyValue.PropertyValue;
111 private void SetPropertyValueByName(
string propertyName,
object propertyValue)
115 throw new SettingsPropertyNotFoundException(
System.
SR.GetString(
"SettingsPropertyNotFound", propertyName));
117 SettingsProperty settingsProperty =
Properties[propertyName];
118 if (settingsProperty ==
null)
120 throw new SettingsPropertyNotFoundException(
System.
SR.GetString(
"SettingsPropertyNotFound", propertyName));
122 if (settingsProperty.IsReadOnly)
124 throw new SettingsPropertyIsReadOnlyException(
System.
SR.GetString(
"SettingsPropertyReadOnly", propertyName));
126 if (propertyValue !=
null && !settingsProperty.PropertyType.IsInstanceOfType(propertyValue))
128 throw new SettingsPropertyWrongTypeException(
System.
SR.GetString(
"SettingsPropertyWrongType", propertyName));
130 SettingsPropertyValue settingsPropertyValue = _PropertyValues[propertyName];
131 if (settingsPropertyValue ==
null)
133 GetPropertiesFromProvider(settingsProperty.Provider);
134 settingsPropertyValue = _PropertyValues[propertyName];
135 if (settingsPropertyValue ==
null)
137 throw new SettingsPropertyNotFoundException(
System.
SR.GetString(
"SettingsPropertyNotFound", propertyName));
140 settingsPropertyValue.PropertyValue = propertyValue;
150 _Properties = properties;
151 _Providers = providers;
170 private void SaveCore()
181 settingsPropertyValueCollection.
Add(propertyValue);
184 if (settingsPropertyValueCollection.
Count > 0)
191 propertyValue2.IsDirty =
false;
196 private void GetPropertiesFromProvider(SettingsProvider provider)
198 SettingsPropertyCollection settingsPropertyCollection =
new SettingsPropertyCollection();
199 foreach (SettingsProperty property
in Properties)
201 if (property.Provider == provider)
203 settingsPropertyCollection.Add(property);
206 if (settingsPropertyCollection.Count > 0)
208 SettingsPropertyValueCollection propertyValues = provider.GetPropertyValues(
Context, settingsPropertyCollection);
209 foreach (SettingsPropertyValue item
in propertyValues)
211 if (_PropertyValues[item.Name] ==
null)
213 _PropertyValues.
Add(item);
224 settingsBase._IsSynchronized =
true;
abstract void SetPropertyValues(SettingsContext context, SettingsPropertyValueCollection collection)
Sets the values of the specified group of property settings.
virtual SettingsProviderCollection Providers
Gets a collection of settings providers.
int Count
Gets a value that specifies the number of T:System.Configuration.SettingsPropertyValue objects in the...
Provides the base class used to support user property settings.
virtual SettingsProvider Provider
Gets or sets the provider for the T:System.Configuration.SettingsProperty.
Contains a collection of settings property values that map T:System.Configuration....
Contains a collection of T:System.Configuration.SettingsProperty objects.
SettingsProperty Property
Gets the T:System.Configuration.SettingsProperty object.
virtual void Save()
Stores the current values of the settings properties.
Represents a collection of application settings providers.
bool IsSynchronized
Gets a value indicating whether access to the object is synchronized (thread safe).
void Add(SettingsPropertyValue property)
Adds a T:System.Configuration.SettingsPropertyValue object to the collection.
void Initialize(SettingsContext context, SettingsPropertyCollection properties, SettingsProviderCollection providers)
Initializes internal properties used by T:System.Configuration.SettingsBase object.
virtual SettingsPropertyCollection Properties
Gets the collection of settings properties.
Contains the value of a settings property that can be loaded and stored by an instance of T:System....
static SettingsBase Synchronized(SettingsBase settingsBase)
Provides a T:System.Configuration.SettingsBase class that is synchronized (thread safe).
Provides contextual information that the provider can use when persisting settings.
virtual SettingsPropertyValueCollection PropertyValues
Gets a collection of settings property values.
SettingsBase()
Initializes a new instance of the T:System.Configuration.SettingsBase class.
Acts as a base class for deriving custom settings providers in the application settings architecture.
int Count
Gets a value that specifies the number of T:System.Configuration.SettingsProperty objects in the coll...
virtual SettingsContext Context
Gets the associated settings context.
Provides an exception for T:System.Configuration.SettingsProperty objects that are not found.