diff options
author | Ivan Zlatev <ivan@ivanz.com> | 2007-08-19 12:24:16 +0400 |
---|---|---|
committer | Ivan Zlatev <ivan@ivanz.com> | 2007-08-19 12:24:16 +0400 |
commit | 917ec97a49ae9a122ee5ee54618b234bae13afd1 (patch) | |
tree | 4db52a5e6cc4be6324b5a1aa92cf284440ef6cd9 /mcs/class/System/System.ComponentModel.Design.Serialization | |
parent | 3b31446cee715207543a757960c24693ee3b665c (diff) |
2007-08-19 Ivan N. Zlatev <contact@i-nz.net>
* ContextStack.cs: Update to 2.0.
* ContextStackTest.cs: New unit tests for ContextStack.
svn path=/trunk/mcs/; revision=84369
Diffstat (limited to 'mcs/class/System/System.ComponentModel.Design.Serialization')
-rw-r--r-- | mcs/class/System/System.ComponentModel.Design.Serialization/ChangeLog | 4 | ||||
-rw-r--r-- | mcs/class/System/System.ComponentModel.Design.Serialization/ContextStack.cs | 48 |
2 files changed, 33 insertions, 19 deletions
diff --git a/mcs/class/System/System.ComponentModel.Design.Serialization/ChangeLog b/mcs/class/System/System.ComponentModel.Design.Serialization/ChangeLog index 6ffcb96cf92..232cce24a2d 100644 --- a/mcs/class/System/System.ComponentModel.Design.Serialization/ChangeLog +++ b/mcs/class/System/System.ComponentModel.Design.Serialization/ChangeLog @@ -1,3 +1,7 @@ +2007-08-18 Ivan N. Zlatev <contact@i-nz.net> + + * ContextStack.cs: Update to 2.0. + 2007-07-21 Gert Driesen <drieseng@users.sourceforge.net> * InstanceDescriptor.cs: Allow null members. Fixed exception messages. diff --git a/mcs/class/System/System.ComponentModel.Design.Serialization/ContextStack.cs b/mcs/class/System/System.ComponentModel.Design.Serialization/ContextStack.cs index 7c1bc952245..e7b0dd96066 100644 --- a/mcs/class/System/System.ComponentModel.Design.Serialization/ContextStack.cs +++ b/mcs/class/System/System.ComponentModel.Design.Serialization/ContextStack.cs @@ -4,9 +4,11 @@ // Author: // Alejandro Sánchez Acosta (raciel@gnome.org) // Andreas Nahr (ClassDevelopment@A-SoftTech.com) +// Ivan N. Zlatev (contact@i-nz.net) // // (C) Alejandro Sánchez Acosta // (C) 2003 Andreas Nahr +// (C) 2007 Ivan N. Zlatev // // @@ -30,35 +32,33 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +using System; using System.Collections; namespace System.ComponentModel.Design.Serialization { public sealed class ContextStack { - private Stack stack; + private ArrayList _contextList; public ContextStack () { - stack = new Stack (); + _contextList = new ArrayList (); } public object Current { get { - try { - return stack.Peek (); - } - catch { - return null; - } + if (_contextList.Count > 0) + return _contextList[_contextList.Count-1]; + return null; } } public object this[Type type] { get { - foreach (object o in stack.ToArray()) - if (o.GetType () == type) - return o; + for (int i = _contextList.Count - 1; i >= 0; i--) + if (_contextList[i].GetType () == type) + return _contextList[i]; return null; } } @@ -67,29 +67,39 @@ namespace System.ComponentModel.Design.Serialization get { if (level < 0) throw new ArgumentException ("level has to be >= 0","level"); - Array A = stack.ToArray(); - if (level > (A.Length - 1)) - return null; - return A.GetValue(level); + if (_contextList.Count > 0 && _contextList.Count > level) + return _contextList[_contextList.Count - 1 - level]; + return null; } } public object Pop () { - return stack.Pop (); + object o = null; + if (_contextList.Count > 0) { + int lastItem = _contextList.Count - 1; + o = _contextList[lastItem]; + _contextList.RemoveAt (lastItem); + } + return o; } public void Push (object context) { - stack.Push (context); + if (context == null) + throw new ArgumentNullException ("context"); + + _contextList.Add (context); } #if NET_2_0 - [MonoNotSupported ("")] public void Append (object context) { - throw new NotImplementedException (); + if (context == null) + throw new ArgumentNullException ("context"); + _contextList.Insert (0, context); } #endif } } + |