// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
//
-#if NET_2_0
using System;
using System.Collections.Specialized;
bool modified;
bool readOnly;
+ int originalStringHash = 0;
public bool IsModified {
- get {
- return modified;
+ get {
+ if (modified)
+ return true;
+
+ string str = ToString ();
+ if (str == null)
+ return false;
+
+ return str.GetHashCode () != originalStringHash;
}
}
public new bool IsReadOnly {
- get {
- return readOnly;
- }
+ get { return readOnly; }
}
- [MonoTODO ("exception type")]
public new string this [int index] {
- get {
- return base [index];
- }
+ get { return base [index]; }
set {
- if (readOnly)
- throw new NotSupportedException (); /* XXX */
+ if (readOnly) throw new ConfigurationErrorsException ("The configuration is read only");
base [index] = value;
modified = true;
}
}
- [MonoTODO ("exception type")]
public new void Add (string value)
{
- if (readOnly)
- throw new NotSupportedException (); /* XXX */
+ if (readOnly) throw new ConfigurationErrorsException ("The configuration is read only");
base.Add (value);
modified = true;
}
- [MonoTODO ("exception type")]
public new void AddRange (string[] range)
{
- if (readOnly)
- throw new NotSupportedException (); /* XXX */
+ if (readOnly) throw new ConfigurationErrorsException ("The configuration is read only");
base.AddRange (range);
modified = true;
}
- [MonoTODO ("exception type")]
public new void Clear ()
{
- if (readOnly)
- throw new NotSupportedException (); /* XXX */
+ if (readOnly) throw new ConfigurationErrorsException ("The configuration is read only");
base.Clear ();
modified = true;
CopyTo (contents, 0);
col.AddRange (contents);
+ col.originalStringHash = originalStringHash;
return col;
}
- [MonoTODO ("exception type")]
public new void Insert (int index, string value)
{
- if (readOnly)
- throw new NotSupportedException (); /* XXX */
+ if (readOnly) throw new ConfigurationErrorsException ("The configuration is read only");
base.Insert (index, value);
modified = true;
}
- [MonoTODO ("exception type")]
public new void Remove (string value)
{
- if (readOnly)
- throw new NotSupportedException (); /* XXX */
+ if (readOnly) throw new ConfigurationErrorsException ("The configuration is read only");
base.Remove (value);
modified = true;
readOnly = true;
}
- public new string ToString ()
+ public override string ToString ()
{
+ if (this.Count == 0)
+ return null;
+
string[] contents = new string[this.Count];
CopyTo (contents, 0);
return String.Join (",", contents);
}
+
+ internal void UpdateStringHash ()
+ {
+ string str = ToString ();
+ if (str == null)
+ originalStringHash = 0;
+ else
+ originalStringHash = str.GetHashCode ();
+ }
}
}
-
-#endif