+2005-12-02 Chris Toshok <toshok@ximian.com>
+
+ * 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 "<!-- dd -->" output.
+
2005-11-28 Chris Toshok <toshok@ximian.com>
* ProviderSettings.cs: use ConfigurationProperty's to implement
#if NET_2_0
+using System.Collections.Specialized;
using System.ComponentModel;
using System.Globalization;
{
if (value == null) return null;
- if (value.GetType() != typeof (CommaDelimitedStringCollection))
+ if (!typeof (StringCollection).IsAssignableFrom (value.GetType()))
throw new ArgumentException ();
return value.ToString ();
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;
}
#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 ();
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)]
get { return (string) base [_propConnectionString]; }
set { base [_propConnectionString] = value; }
}
-
- #endregion // Properties
public override string ToString ()
{
#if NET_2_0
-#region Using directives
using System;
-#endregion
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;
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);
[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;
{
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);
((ConnectionStringSettings) element).Name));
this [index] = (ConnectionStringSettings) element;
}
-
- #endregion // Methods
-
}
}
#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),
_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 ()
}
ConfigurationPropertyCollection properties;
- [MonoTODO]
protected internal override ConfigurationPropertyCollection Properties {
get {
if (properties == null)
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;
}
xml = section.SerializeSection (parentSection, Name, mode);
}
else {
- xml = config.GetSectionXml (this) + " <!-- dd -->";
+ xml = config.GetSectionXml (this);
}
if (xml != null) {