diff options
author | Todd Berman <tberman@mono-cvs.ximian.com> | 2003-11-18 19:56:19 +0300 |
---|---|---|
committer | Todd Berman <tberman@mono-cvs.ximian.com> | 2003-11-18 19:56:19 +0300 |
commit | 7e9e390ccff3997e9508d2b3dbf9d63a6c946255 (patch) | |
tree | 752a3faf8332b5fcbd159326a86132a6d77582b0 /mcs | |
parent | 1624abe136563f00e2e14aae894fb618350c744d (diff) |
2003-11-18 Todd Berman <tberman@gentoo.org>
* ParameterCollection.cs: Implemented
* Parameter.cs: Added _owner, SetOwnerCollection and proper handling.
ToString () now matches asp.net
svn path=/trunk/mcs/; revision=20177
Diffstat (limited to 'mcs')
3 files changed, 213 insertions, 3 deletions
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog b/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog index 8799e43891a..449b979742e 100644 --- a/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog +++ b/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog @@ -1,3 +1,9 @@ +2003-11-18 Todd Berman <tberman@gentoo.org> + + * ParameterCollection.cs: Implemented + * Parameter.cs: Added _owner, SetOwnerCollection and proper handling. + ToString () now matches asp.net + 2003-11-17 Ben Maurer <bmaurer@users.sourceforge.net> * ControlParameter.cs: diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/Parameter.cs b/mcs/class/System.Web/System.Web.UI.WebControls/Parameter.cs index 1264bc7054d..5f89f782655 100644 --- a/mcs/class/System.Web/System.Web.UI.WebControls/Parameter.cs +++ b/mcs/class/System.Web/System.Web.UI.WebControls/Parameter.cs @@ -51,6 +51,8 @@ namespace System.Web.UI.WebControls { protected void OnParameterChanged () { + if (_owner != null) + _owner.ParameterChanged (); } protected virtual void LoadViewState (object savedState) @@ -99,10 +101,9 @@ namespace System.Web.UI.WebControls { get { return this.IsTrackingViewState; } } - [MonoTODO] public override string ToString () { - return base.ToString (); + return Name; } public string DefaultValue { @@ -205,7 +206,12 @@ namespace System.Web.UI.WebControls { get { return isTrackingViewState; } } - + private ParameterCollection _owner; + + internal void SetOwnerCollection (ParameterCollection own) + { + _owner = own; + } } } #endif diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/ParameterCollection.cs b/mcs/class/System.Web/System.Web.UI.WebControls/ParameterCollection.cs new file mode 100644 index 00000000000..be3d8a92a6f --- /dev/null +++ b/mcs/class/System.Web/System.Web.UI.WebControls/ParameterCollection.cs @@ -0,0 +1,198 @@ +// +// System.Web.UI.WebControls/ParameterCollection.cs +// +// Author: Todd Berman <tberman@gentoo.org> +// +// (C) 2003 Todd Berman + +#if NET_1_2 + +using System.Web.UI; +using System.Collections.Specialized; + +namespace System.Web.UI.WebControls +{ + + public class ParameterCollection : StateManagedCollection + { + + private static Type[] _knownTypes = new Type[] { + typeof (ControlParameter), + typeof (CookieParameter), + typeof (FormParameter), + typeof (Parameter), + typeof (QueryStringParameter), + typeof (SessionParameter) }; + + private EventHandler _parametersChanged; + private KeyedList _values; + + + public int Add (Parameter param) + { + return base.Add (param); + } + + public int Add (string name, string value) + { + return base.Add (new Parameter (name, 1, value)); + } + + public int Add (string name, TypeCode type, string value) + { + return base.Add (new Parameter (name, type, value)); + } + + protected override object CreateKnownType (int idx) + { + switch (idx) { + case 0: + return new ControlParameter (); + break; + case 1: + return new CookieParameter (); + break; + case 2: + return new FormParameter (); + break; + case 3: + return new Parameter (); + break; + case 4: + return new QueryStringParameter (); + break; + case 5: + return new SessionParameter (); + break; + } + + throw new ArgumentOutOfRangeException ("index"); + } + + protected override Type[] GetKnownTypes () + { + return _knownTypes; + } + + public IOrderedDictionary GetValues (Control control) + { + if (_values == null) + { + _values = new KeyedList (); + foreach (Parameter param in this) + { + string name = param.Name; + for (int i = 1; _values.Contains (name); i++) + { + name = param.Name + i.ToString (); + } + _values.Add (name, param.ParameterValue); + } + } + return _values; + } + + public void Insert (int idx, Parameter param) + { + base.Insert (idx, param); + } + + protected override void OnClearComplete () + { + base.OnClearComplete (); + OnParametersChanged (EventArgs.Empty); + } + + protected override void OnInsert (int idx, object value) + { + base.OnInsert (idx, value); + ((Parameter)value).SetOwnerCollection (this); + } + + protected override void OnInsertComplete (int idx, object value) + { + base.OnInsertComplete (idx, value); + OnParametersChanged (EventArgs.Empty); + } + + protected virtual void OnParametersChanged (EventArgs e) + { + if (_parametersChanged != null) + _parametersChanged.Invoke (this, e); + + _values = null; + } + + protected override void OnValidate (object o) + { + base.OnValidate (o); + + if (!o is Parameter) + throw new ArgumentException ("o is not a Parameter"); + } + + public void Remove (Parameter param) + { + base.Remove (param); + } + + public void RemoveAt (int idx) + { + base.RemoveAr (idx); + } + + protected override void SetDirtyObject (object o) + { + ((Parameter)o).SetDirty(); + } + + internal void ParametersChanged () + { + OnParametersChanged (EventArgs.Empty); + } + + private int Contains (string name) + { + for (int i = 0; i < Count; i++) + { + if (this[i].Name == name) + return i; + } + return -1; + } + + public Parameter this[int idx] { + get { + return (Parameter) base[idx]; + } + set { + base[idx] = value; + } + } + + public Parameter this[string name] { + get { + int idx = IndexOfString (name); + if (idx == -1) + return null; + return this[idx]; + } + set { + int idx = IndexOfString (name); + if (idx == -1) { + Add (value); + return; + } + this[idx] = value; + } + } + + public event EventHandler ParametersChanged { + get { _parametersChanged += value; } + set { _parametersChanged -= value; } + } + + } +} + +#endif |