From 915392218f88b988637329147dd3a96f04afcdb9 Mon Sep 17 00:00:00 2001 From: Chris Toshok Date: Fri, 2 Dec 2005 23:46:12 +0000 Subject: [PATCH] 2005-12-02 Chris Toshok * CommaDelimitedStringCollectionConverter.cs (ConvertTo): change the type check away from an exact check for CommaDelimitedStringCollection to an assignable test from StringCollection. This is due to the fact that AuthorizationRule doesn't create CommaDelimitedStringCollections, for some odd reason. It uses StringCollections. * PropertyInformation.cs (Value): remove the case for IsDefaultCollection - it's not necessary, as the property is an Element. * ConnectionStringSettings.cs: fix formatting and remove some #regions. * ConnectionStringSettingsCollection.cs: same. * ConnectionStringsSection.cs: same. * ConfigurationElement.cs (SerializeToXmlElement): don't write the enclosing start/end elements if the elementName is null or "". this fixes the case for the DefaultCollections (at least in the case of connectionStrings). * IgnoreSection.cs (Properties): remove the MonoTODO. * SectionInfo.cs (WriteData): remove the "" output. svn path=/trunk/mcs/; revision=53858 --- .../System.Configuration/ChangeLog | 29 ++++++++++++++++ ...CommaDelimitedStringCollectionConverter.cs | 3 +- .../ConfigurationElement.cs | 6 ++-- .../ConnectionStringSettings.cs | 18 +--------- .../ConnectionStringSettingsCollection.cs | 31 ++++++----------- .../ConnectionStringsSection.cs | 34 +++---------------- .../System.Configuration/IgnoreSection.cs | 1 - .../PropertyInformation.cs | 8 ----- .../System.Configuration/SectionInfo.cs | 2 +- 9 files changed, 52 insertions(+), 80 deletions(-) diff --git a/mcs/class/System.Configuration/System.Configuration/ChangeLog b/mcs/class/System.Configuration/System.Configuration/ChangeLog index c07659097a8..208099a2250 100644 --- a/mcs/class/System.Configuration/System.Configuration/ChangeLog +++ b/mcs/class/System.Configuration/System.Configuration/ChangeLog @@ -1,3 +1,32 @@ +2005-12-02 Chris Toshok + + * CommaDelimitedStringCollectionConverter.cs (ConvertTo): change + the type check away from an exact check for + CommaDelimitedStringCollection to an assignable test from + StringCollection. This is due to the fact that AuthorizationRule + doesn't create CommaDelimitedStringCollections, for some odd + reason. It uses StringCollections. + + * PropertyInformation.cs (Value): remove the case for + IsDefaultCollection - it's not necessary, as the property is an + Element. + + * ConnectionStringSettings.cs: fix formatting and remove some + #regions. + + * ConnectionStringSettingsCollection.cs: same. + + * ConnectionStringsSection.cs: same. + + * ConfigurationElement.cs (SerializeToXmlElement): don't write the + enclosing start/end elements if the elementName is null or "". + this fixes the case for the DefaultCollections (at least in the + case of connectionStrings). + + * IgnoreSection.cs (Properties): remove the MonoTODO. + + * SectionInfo.cs (WriteData): remove the "" output. + 2005-11-28 Chris Toshok * ProviderSettings.cs: use ConfigurationProperty's to implement diff --git a/mcs/class/System.Configuration/System.Configuration/CommaDelimitedStringCollectionConverter.cs b/mcs/class/System.Configuration/System.Configuration/CommaDelimitedStringCollectionConverter.cs index f2e9c011785..1ce8d3dc31e 100644 --- a/mcs/class/System.Configuration/System.Configuration/CommaDelimitedStringCollectionConverter.cs +++ b/mcs/class/System.Configuration/System.Configuration/CommaDelimitedStringCollectionConverter.cs @@ -28,6 +28,7 @@ #if NET_2_0 +using System.Collections.Specialized; using System.ComponentModel; using System.Globalization; @@ -54,7 +55,7 @@ namespace System.Configuration { if (value == null) return null; - if (value.GetType() != typeof (CommaDelimitedStringCollection)) + if (!typeof (StringCollection).IsAssignableFrom (value.GetType())) throw new ArgumentException (); return value.ToString (); diff --git a/mcs/class/System.Configuration/System.Configuration/ConfigurationElement.cs b/mcs/class/System.Configuration/System.Configuration/ConfigurationElement.cs index 423ff1128da..c9c817d20b8 100644 --- a/mcs/class/System.Configuration/System.Configuration/ConfigurationElement.cs +++ b/mcs/class/System.Configuration/System.Configuration/ConfigurationElement.cs @@ -443,9 +443,11 @@ namespace System.Configuration protected internal virtual bool SerializeToXmlElement ( XmlWriter writer, string elementName) { - writer.WriteStartElement (elementName); + if (elementName != null && elementName != "") + writer.WriteStartElement (elementName); bool res = SerializeElement (writer, false); - writer.WriteEndElement (); + if (elementName != null && elementName != "") + writer.WriteEndElement (); return res; } diff --git a/mcs/class/System.Configuration/System.Configuration/ConnectionStringSettings.cs b/mcs/class/System.Configuration/System.Configuration/ConnectionStringSettings.cs index 8bcccf964ca..7310287af63 100644 --- a/mcs/class/System.Configuration/System.Configuration/ConnectionStringSettings.cs +++ b/mcs/class/System.Configuration/System.Configuration/ConnectionStringSettings.cs @@ -30,26 +30,18 @@ #if NET_2_0 -#region Using directives - using System; -#endregion - namespace System.Configuration { public sealed class ConnectionStringSettings : ConfigurationElement { - - #region Fields private static ConfigurationPropertyCollection _properties; private static readonly ConfigurationProperty _propConnectionString; private static readonly ConfigurationProperty _propName; private static readonly ConfigurationProperty _propProviderName; - #endregion // Fields - #region Constructors static ConnectionStringSettings () { _properties = new ConfigurationPropertyCollection (); @@ -93,16 +85,10 @@ namespace System.Configuration ConnectionString = connectionString; ProviderName = providerName; } - #endregion // Constructors - - #region Properties protected internal override ConfigurationPropertyCollection Properties { - get - { - return _properties; - } + get { return _properties; } } [ConfigurationProperty ("name", DefaultValue = "", Options = ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey)] @@ -125,8 +111,6 @@ namespace System.Configuration get { return (string) base [_propConnectionString]; } set { base [_propConnectionString] = value; } } - - #endregion // Properties public override string ToString () { diff --git a/mcs/class/System.Configuration/System.Configuration/ConnectionStringSettingsCollection.cs b/mcs/class/System.Configuration/System.Configuration/ConnectionStringSettingsCollection.cs index e48bf14164d..20402e2d849 100644 --- a/mcs/class/System.Configuration/System.Configuration/ConnectionStringSettingsCollection.cs +++ b/mcs/class/System.Configuration/System.Configuration/ConnectionStringSettingsCollection.cs @@ -29,9 +29,7 @@ #if NET_2_0 -#region Using directives using System; -#endregion namespace System.Configuration { @@ -40,17 +38,13 @@ namespace System.Configuration public sealed class ConnectionStringSettingsCollection : ConfigurationElementCollection { - #region Constructors public ConnectionStringSettingsCollection () : base () { } - #endregion // Constructors - #region Properties public new ConnectionStringSettings this [string Name] { - get - { + get { foreach (ConfigurationElement c in this) { if (!(c is ConnectionStringSettings)) continue; @@ -64,12 +58,8 @@ namespace System.Configuration public new ConnectionStringSettings this [int index] { - get - { - return (ConnectionStringSettings) BaseGet (index); - } - set - { + get { return (ConnectionStringSettings) BaseGet (index); } + set { if (BaseGet (index) != null) BaseRemoveAt (index); BaseAdd (index, value); @@ -78,18 +68,15 @@ namespace System.Configuration [MonoTODO] protected internal override ConfigurationPropertyCollection Properties { - get { - return base.Properties; - } + get { return base.Properties; } } - #endregion // Properties - #region Methods protected override ConfigurationElement CreateNewElement () { return new ConnectionStringSettings ("", "", ""); } + protected override object GetElementKey (ConfigurationElement element) { return ((ConnectionStringSettings) element).Name; @@ -99,22 +86,27 @@ namespace System.Configuration { BaseAdd ((ConfigurationElement) settings); } + public void Clear () { BaseClear (); } + public int IndexOf (ConnectionStringSettings settings) { return BaseIndexOf (settings); } + public void Remove (ConnectionStringSettings settings) { BaseRemove (settings.Name); } + public void Remove (string name) { BaseRemove (name); } + public void RemoveAt (int index) { BaseRemoveAt (index); @@ -129,9 +121,6 @@ namespace System.Configuration ((ConnectionStringSettings) element).Name)); this [index] = (ConnectionStringSettings) element; } - - #endregion // Methods - } } diff --git a/mcs/class/System.Configuration/System.Configuration/ConnectionStringsSection.cs b/mcs/class/System.Configuration/System.Configuration/ConnectionStringsSection.cs index ba36a5baa71..5195721dff4 100644 --- a/mcs/class/System.Configuration/System.Configuration/ConnectionStringsSection.cs +++ b/mcs/class/System.Configuration/System.Configuration/ConnectionStringsSection.cs @@ -31,22 +31,16 @@ #if NET_2_0 -#region Using directives using System; using System.Xml; -#endregion namespace System.Configuration { public sealed class ConnectionStringsSection : ConfigurationSection { - - #region Fields private static readonly ConfigurationProperty _propConnectionStrings; private static ConfigurationPropertyCollection _properties; - #endregion // Fields - #region Constructors static ConnectionStringsSection () { _propConnectionStrings = new ConfigurationProperty (null, typeof (ConnectionStringSettingsCollection), @@ -54,40 +48,22 @@ namespace System.Configuration _properties = new ConfigurationPropertyCollection (); _properties.Add (_propConnectionStrings); } - public ConnectionStringsSection () : base () + + public ConnectionStringsSection () { } - #endregion // Constructors - #region Properties - ConnectionStringSettingsCollection strings; + [ConfigurationProperty ("", Options = ConfigurationPropertyOptions.IsDefaultCollection)] public ConnectionStringSettingsCollection ConnectionStrings { - get { - if (strings == null) - strings = new ConnectionStringSettingsCollection (); - return strings; -#if false - return (ConnectionStringSettingsCollection) base [_propConnectionStrings]; -#endif - } + get { return (ConnectionStringSettingsCollection) base [_propConnectionStrings]; } } - [MonoTODO ("this shouldn't be here, but it's necessary until the ConfigurationPropertyOptions.IsDefaultCollection stuff is hooked up properly.")] - protected internal override void DeserializeElement (XmlReader reader, bool serializeCollectionKey) - { - ConnectionStrings.DeserializeElement (reader, serializeCollectionKey); - } - protected internal override ConfigurationPropertyCollection Properties { - get - { - return _properties; - } + get { return _properties; } } - #endregion // Properties protected internal override object GetRuntimeObject () diff --git a/mcs/class/System.Configuration/System.Configuration/IgnoreSection.cs b/mcs/class/System.Configuration/System.Configuration/IgnoreSection.cs index df38935c865..8a9f1962d22 100644 --- a/mcs/class/System.Configuration/System.Configuration/IgnoreSection.cs +++ b/mcs/class/System.Configuration/System.Configuration/IgnoreSection.cs @@ -71,7 +71,6 @@ namespace System.Configuration { } ConfigurationPropertyCollection properties; - [MonoTODO] protected internal override ConfigurationPropertyCollection Properties { get { if (properties == null) diff --git a/mcs/class/System.Configuration/System.Configuration/PropertyInformation.cs b/mcs/class/System.Configuration/System.Configuration/PropertyInformation.cs index a91e4a60d7e..823945045d5 100644 --- a/mcs/class/System.Configuration/System.Configuration/PropertyInformation.cs +++ b/mcs/class/System.Configuration/System.Configuration/PropertyInformation.cs @@ -115,14 +115,6 @@ namespace System.Configuration val = elem; origin = PropertyValueOrigin.Inherited; } - else if (property.IsDefaultCollection) { - ConfigurationElementCollection col = (ConfigurationElementCollection) Activator.CreateInstance (Type); - col.InitFromProperty (this); - if (owner != null && owner.IsReadOnly ()) - col.SetReadOnly (); - val = col; - origin = PropertyValueOrigin.Inherited; - } else { return DefaultValue; } diff --git a/mcs/class/System.Configuration/System.Configuration/SectionInfo.cs b/mcs/class/System.Configuration/System.Configuration/SectionInfo.cs index bb22167fd53..06f4fe37f2a 100644 --- a/mcs/class/System.Configuration/System.Configuration/SectionInfo.cs +++ b/mcs/class/System.Configuration/System.Configuration/SectionInfo.cs @@ -171,7 +171,7 @@ namespace System.Configuration xml = section.SerializeSection (parentSection, Name, mode); } else { - xml = config.GetSectionXml (this) + " "; + xml = config.GetSectionXml (this); } if (xml != null) { -- 2.25.1