You've already forked linux-packaging-mono
Imported Upstream version 5.12.0.220
Former-commit-id: c477e03582759447177c6d4bf412cd2355aad476
This commit is contained in:
parent
8bd104cef2
commit
8fc30896db
@ -78,9 +78,13 @@ namespace System.Configuration {
|
||||
public void Reload ()
|
||||
{
|
||||
#if (CONFIGURATION_DEP)
|
||||
foreach (SettingsProvider provider in Providers) {
|
||||
// IApplicationSettingsProvider iasp = provider as IApplicationSettingsProvider;
|
||||
CacheValuesByProvider(provider);
|
||||
/* Clear out the old property values so they will be reloaded on request */
|
||||
if (PropertyValues != null) {
|
||||
PropertyValues.Clear();
|
||||
}
|
||||
foreach(SettingsProperty prop in Properties) {
|
||||
/* emit PropertyChanged for every property */
|
||||
OnPropertyChanged(this, new PropertyChangedEventArgs(prop.Name));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -88,13 +92,31 @@ namespace System.Configuration {
|
||||
public void Reset()
|
||||
{
|
||||
#if (CONFIGURATION_DEP)
|
||||
if (Properties != null) {
|
||||
foreach (SettingsProvider provider in Providers) {
|
||||
IApplicationSettingsProvider iasp = provider as IApplicationSettingsProvider;
|
||||
if (iasp != null)
|
||||
iasp.Reset (Context);
|
||||
}
|
||||
InternalSave ();
|
||||
}
|
||||
|
||||
Reload ();
|
||||
foreach (SettingsPropertyValue pv in PropertyValues)
|
||||
pv.PropertyValue = pv.Reset();
|
||||
#endif
|
||||
}
|
||||
|
||||
public override void Save()
|
||||
public override void Save ()
|
||||
{
|
||||
var e = new CancelEventArgs ();
|
||||
|
||||
OnSettingsSaving (this, e);
|
||||
if (e.Cancel)
|
||||
return;
|
||||
|
||||
InternalSave ();
|
||||
}
|
||||
|
||||
void InternalSave ()
|
||||
{
|
||||
#if (CONFIGURATION_DEP)
|
||||
Context.CurrentSettings = this;
|
||||
@ -111,13 +133,42 @@ namespace System.Configuration {
|
||||
provider.SetPropertyValues (Context, cache);
|
||||
}
|
||||
Context.CurrentSettings = null;
|
||||
#else
|
||||
throw new NotImplementedException("No useful Save implemented.");
|
||||
#endif
|
||||
}
|
||||
|
||||
public virtual void Upgrade()
|
||||
public virtual void Upgrade ()
|
||||
{
|
||||
#if (CONFIGURATION_DEP)
|
||||
// if there is a current property, then for each settings
|
||||
// provider in the providers collection, upgrade(ssp)
|
||||
if (Properties != null) {
|
||||
foreach (SettingsProvider provider in Providers) {
|
||||
var appSettingsProvider = provider as IApplicationSettingsProvider;
|
||||
if(appSettingsProvider != null) {
|
||||
appSettingsProvider.Upgrade (Context, GetPropertiesForProvider (provider));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reload ();
|
||||
#else
|
||||
throw new NotImplementedException ("No useful Upgrade implemented");
|
||||
#endif
|
||||
}
|
||||
|
||||
private SettingsPropertyCollection GetPropertiesForProvider (SettingsProvider provider)
|
||||
{
|
||||
SettingsPropertyCollection properties = new SettingsPropertyCollection ();
|
||||
foreach (SettingsProperty sp in Properties) {
|
||||
if (sp.Provider == provider) {
|
||||
properties.Add(sp);
|
||||
}
|
||||
}
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
||||
protected virtual void OnPropertyChanged (object sender,
|
||||
PropertyChangedEventArgs e)
|
||||
{
|
||||
@ -310,7 +361,17 @@ namespace System.Configuration {
|
||||
foreach (Attribute a in prop.GetCustomAttributes (false)) {
|
||||
/* the attributes we handle natively here */
|
||||
if (a is SettingsProviderAttribute) {
|
||||
Type provider_type = Type.GetType (((SettingsProviderAttribute)a).ProviderTypeName);
|
||||
var providerTypeName = ((SettingsProviderAttribute)a).ProviderTypeName;
|
||||
Type provider_type = Type.GetType (providerTypeName);
|
||||
if(provider_type == null) { // Type failed to find the type by name
|
||||
var typeNameParts = providerTypeName.Split('.');
|
||||
if(typeNameParts.Length > 1) { //Load the assembly that providerTypeName claims
|
||||
var assy = Assembly.Load(typeNameParts[0]);
|
||||
if(assy != null) {
|
||||
provider_type = assy.GetType(providerTypeName); //try to get the type from that Assembly
|
||||
}
|
||||
}
|
||||
}
|
||||
provider = (SettingsProvider) Activator.CreateInstance (provider_type);
|
||||
provider.Initialize (null, null);
|
||||
}
|
||||
|
Reference in New Issue
Block a user