From 8b1be8be0b90d8e029a2f03a0de42f74ba38f6dc Mon Sep 17 00:00:00 2001 From: Chris Toshok Date: Wed, 28 Sep 2005 22:48:41 +0000 Subject: [PATCH] 2005-09-28 Chris Toshok * ConfigurationElementCollection.cs: more work on the "" handling - just skip the element for now. this causes a failure in one test ('' doesn't throw an exception when it should), but it succeeds for collections that have required attributes. * ConnectionStringSettings.cs: providerName isn't a required attribute. * AppSettingsSection.cs (.cctor): initialize our "file" Property. (File): implement. (Properties): fix. (GetRuntimeObject): call the base class method instead of just returning "this". * ConnectionStringsSection.cs: Add a hacky DeserializeElement method here (that isn't in MS's) for the time being so we actually deserialize our collection. svn path=/trunk/mcs/; revision=50977 --- .../AppSettingsSection.cs | 30 ++++++++++++++----- .../System.Configuration/ChangeLog | 21 +++++++++++++ .../ConfigurationElementCollection.cs | 3 +- .../ConnectionStringSettings.cs | 2 +- .../ConnectionStringsSection.cs | 16 ++++++++-- 5 files changed, 59 insertions(+), 13 deletions(-) diff --git a/mcs/class/System.Configuration/System.Configuration/AppSettingsSection.cs b/mcs/class/System.Configuration/System.Configuration/AppSettingsSection.cs index 2363405ed85..6d3d64daf61 100644 --- a/mcs/class/System.Configuration/System.Configuration/AppSettingsSection.cs +++ b/mcs/class/System.Configuration/System.Configuration/AppSettingsSection.cs @@ -3,6 +3,7 @@ // // Authors: // Duncan Mak (duncan@ximian.com) +// Chris Toshok (toshok@ximian.com) // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -37,7 +38,22 @@ namespace System.Configuration { public sealed class AppSettingsSection : ConfigurationSection { KeyValueConfigurationCollection values; - + const string configFile = "file"; + + private static ConfigurationPropertyCollection _properties; + private static readonly ConfigurationProperty _propFile; + + static AppSettingsSection () + { + _properties = new ConfigurationPropertyCollection (); + _propFile = new ConfigurationProperty (configFile, + typeof(string), + "", + ConfigurationPropertyOptions.None); + + _properties.Add (_propFile); + } + public AppSettingsSection () { } @@ -67,11 +83,10 @@ namespace System.Configuration { throw new NotImplementedException (); } - [MonoTODO] [ConfigurationProperty ("file", DefaultValue = "")] public string File { - get { throw new NotImplementedException (); } - set { throw new NotImplementedException (); } + get { return (string)base [configFile]; } + set { base [configFile] = value; } } [ConfigurationProperty ("", DefaultValue = "System.Object", Options = ConfigurationPropertyOptions.IsDefaultCollection)] @@ -83,17 +98,16 @@ namespace System.Configuration { } } - [MonoTODO] - public new ConfigurationPropertyCollection Properties { + protected internal override ConfigurationPropertyCollection Properties { get { - return base.Properties; + return _properties; } } [MonoTODO] protected internal override object GetRuntimeObject () { - return this; + return base.GetRuntimeObject(); } } } diff --git a/mcs/class/System.Configuration/System.Configuration/ChangeLog b/mcs/class/System.Configuration/System.Configuration/ChangeLog index b0459f55017..cd6d1346336 100644 --- a/mcs/class/System.Configuration/System.Configuration/ChangeLog +++ b/mcs/class/System.Configuration/System.Configuration/ChangeLog @@ -1,3 +1,24 @@ +2005-09-28 Chris Toshok + + * ConfigurationElementCollection.cs: more work on the "" + handling - just skip the element for now. this causes a failure + in one test ('' doesn't throw an exception when + it should), but it succeeds for collections that have required + attributes. + + * ConnectionStringSettings.cs: providerName isn't a required + attribute. + + * AppSettingsSection.cs (.cctor): initialize our "file" Property. + (File): implement. + (Properties): fix. + (GetRuntimeObject): call the base class method instead of just + returning "this". + + * ConnectionStringsSection.cs: Add a hacky DeserializeElement + method here (that isn't in MS's) for the time being so we actually + deserialize our collection. + 2005-09-28 Chris Toshok * KeyValueInternalCollection.cs: found this by way of a stack diff --git a/mcs/class/System.Configuration/System.Configuration/ConfigurationElementCollection.cs b/mcs/class/System.Configuration/System.Configuration/ConfigurationElementCollection.cs index 319eae20b68..fe3021c3912 100644 --- a/mcs/class/System.Configuration/System.Configuration/ConfigurationElementCollection.cs +++ b/mcs/class/System.Configuration/System.Configuration/ConfigurationElementCollection.cs @@ -445,8 +445,7 @@ namespace System.Configuration } else { if (elementName == clearElementName) { - ConfigurationElement elem = CreateNewElementInternal (null); - elem.DeserializeElement (reader, true); + reader.Skip (); BaseClear (); emitClear = true; modified = false; diff --git a/mcs/class/System.Configuration/System.Configuration/ConnectionStringSettings.cs b/mcs/class/System.Configuration/System.Configuration/ConnectionStringSettings.cs index 1f36411019a..8bcccf964ca 100644 --- a/mcs/class/System.Configuration/System.Configuration/ConnectionStringSettings.cs +++ b/mcs/class/System.Configuration/System.Configuration/ConnectionStringSettings.cs @@ -63,7 +63,7 @@ namespace System.Configuration _propProviderName = new ConfigurationProperty ("providerName", typeof (string), "", - ConfigurationPropertyOptions.IsRequired + ConfigurationPropertyOptions.None ); _propConnectionString = new ConfigurationProperty ("connectionString", diff --git a/mcs/class/System.Configuration/System.Configuration/ConnectionStringsSection.cs b/mcs/class/System.Configuration/System.Configuration/ConnectionStringsSection.cs index bc15ea17bc8..9cf6fb42c51 100644 --- a/mcs/class/System.Configuration/System.Configuration/ConnectionStringsSection.cs +++ b/mcs/class/System.Configuration/System.Configuration/ConnectionStringsSection.cs @@ -33,6 +33,7 @@ #region Using directives using System; +using System.Xml; #endregion namespace System.Configuration @@ -58,12 +59,23 @@ namespace System.Configuration } #endregion // Constructors + protected internal override void DeserializeElement (XmlReader reader, bool serializeCollectionKey) + { + ConnectionStrings.DeserializeElement (reader, serializeCollectionKey); + } + #region Properties + ConnectionStringSettingsCollection strings; + [ConfigurationProperty ("", DefaultValue = "System.Object", Options = ConfigurationPropertyOptions.IsDefaultCollection)] public ConnectionStringSettingsCollection ConnectionStrings { - get - { + get { + if (strings == null) + strings = new ConnectionStringSettingsCollection (); + return strings; +#if false return (ConnectionStringSettingsCollection) base [_propConnectionStrings]; +#endif } } protected internal override ConfigurationPropertyCollection Properties -- 2.25.1