diff options
author | Iain McCoy <iainmc@mono-cvs.ximian.com> | 2005-07-18 20:29:06 +0400 |
---|---|---|
committer | Iain McCoy <iainmc@mono-cvs.ximian.com> | 2005-07-18 20:29:06 +0400 |
commit | c063abca55521fb1fd7e03ffd98adfc2b4898b12 (patch) | |
tree | dd4d0913c9a65e50881a5ced20678fb01736b7ad /mcs/class/WindowsBase | |
parent | e58d1ac64815170598fee921f87b7502b3e51bf9 (diff) |
2005-07-18 Iain McCoy <iain@mccoy.id.au>
* Mono.Windows.Serialization/*, Test/*: change stupid
CreateElementText name of method on XamlWriter to something marginally
more sensible
* demo/TestVocab/*.cs: add implementations of equals so that tests for
the ObjectWriter can be written.
2005-07-19 Iain McCoy <iain@mccoy.id.au>
* System.Windows/DependencyObject.cs,
System.Windows/LocalValueEnumerator.cs: implemented
GetLocalValueEnumerator() and the LocalValueEnumerator class to
support it.
* Test/DependencyObject.cs: added test for LocalValueEnumerator
svn path=/trunk/mcs/; revision=47391
Diffstat (limited to 'mcs/class/WindowsBase')
-rw-r--r-- | mcs/class/WindowsBase/ChangeLog | 9 | ||||
-rw-r--r-- | mcs/class/WindowsBase/System.Windows/DependencyObject.cs | 2 | ||||
-rw-r--r-- | mcs/class/WindowsBase/System.Windows/LocalValueEnumerator.cs | 24 | ||||
-rw-r--r-- | mcs/class/WindowsBase/Test/AttachedProperties.cs | 38 |
4 files changed, 60 insertions, 13 deletions
diff --git a/mcs/class/WindowsBase/ChangeLog b/mcs/class/WindowsBase/ChangeLog index 14baa7d2e81..e4967da5941 100644 --- a/mcs/class/WindowsBase/ChangeLog +++ b/mcs/class/WindowsBase/ChangeLog @@ -1,3 +1,12 @@ +2005-07-19 Iain McCoy <iain@mccoy.id.au> + + * System.Windows/DependencyObject.cs, + System.Windows/LocalValueEnumerator.cs: implemented + GetLocalValueEnumerator() and the LocalValueEnumerator class to + support it. + * Test/DependencyObject.cs: added test for LocalValueEnumerator + + 2005-07-06 Iain McCoy <iain@mccoy.id.au> * System.Windows/DependencyObject.cs, diff --git a/mcs/class/WindowsBase/System.Windows/DependencyObject.cs b/mcs/class/WindowsBase/System.Windows/DependencyObject.cs index 798894017a9..81038c3b8c6 100644 --- a/mcs/class/WindowsBase/System.Windows/DependencyObject.cs +++ b/mcs/class/WindowsBase/System.Windows/DependencyObject.cs @@ -53,7 +53,7 @@ namespace System.Windows { [MonoTODO()] public LocalValueEnumerator GetLocalValueEnumerator() { - throw new NotImplementedException("GetLocalValueEnumerator()"); + return new LocalValueEnumerator(properties); } public object GetValue(DependencyProperty dp) diff --git a/mcs/class/WindowsBase/System.Windows/LocalValueEnumerator.cs b/mcs/class/WindowsBase/System.Windows/LocalValueEnumerator.cs index 67d040fc8e3..1639428e620 100644 --- a/mcs/class/WindowsBase/System.Windows/LocalValueEnumerator.cs +++ b/mcs/class/WindowsBase/System.Windows/LocalValueEnumerator.cs @@ -31,26 +31,34 @@ using System.Collections; namespace System.Windows { public struct LocalValueEnumerator : IEnumerator { - [MonoTODO()] + private IDictionaryEnumerator propertyEnumerator; + private Hashtable properties; + + private int count; + internal LocalValueEnumerator(Hashtable properties) + { + this.count = properties.Count; + this.properties = properties; + this.propertyEnumerator = properties.GetEnumerator(); + } + public int Count { - get { throw new NotImplementedException(); } + get { return count; } } - [MonoTODO()] public LocalValueEntry Current { - get { throw new NotImplementedException(); } + get { return new LocalValueEntry((DependencyProperty)propertyEnumerator.Key, + propertyEnumerator.Value); } } object IEnumerator.Current { get { return this.Current; } } - [MonoTODO()] public bool MoveNext() { - throw new NotImplementedException(); + return propertyEnumerator.MoveNext(); } - [MonoTODO()] public void Reset() { - throw new NotImplementedException(); + propertyEnumerator.Reset(); } } } diff --git a/mcs/class/WindowsBase/Test/AttachedProperties.cs b/mcs/class/WindowsBase/Test/AttachedProperties.cs index f42f6166d44..6f6119b1a67 100644 --- a/mcs/class/WindowsBase/Test/AttachedProperties.cs +++ b/mcs/class/WindowsBase/Test/AttachedProperties.cs @@ -28,13 +28,24 @@ class X { { return (int)obj.GetValue(AProperty); } + + public static readonly DependencyProperty BProperty = DependencyProperty.RegisterAttached("B", typeof(string), typeof(X)); + public static void SetB(DependencyObject obj, string value) + { + obj.SetValue(BProperty, value); + } + public static string GetB(DependencyObject obj) + { + return (string)obj.GetValue(BProperty); + } + } class Y : DependencyObject { } [TestFixture] -public class DependencyObjectTest : Assertion { +public class DependencyObjectTest { [SetUp] public void GetReady() {} @@ -47,7 +58,7 @@ public class DependencyObjectTest : Assertion { { Y y1 = new Y(); X.SetA(y1, 2); - AssertEquals(2, X.GetA(y1)); + Assert.AreEqual(2, X.GetA(y1)); } [Test] @@ -57,8 +68,27 @@ public class DependencyObjectTest : Assertion { Y y2 = new Y(); X.SetA(y1, 2); X.SetA(y2, 3); - AssertEquals(2, X.GetA(y1)); - AssertEquals(3, X.GetA(y2)); + Assert.AreEqual(2, X.GetA(y1)); + Assert.AreEqual(3, X.GetA(y2)); + } + + [Test] + public void TestEnumerationOfAttachedProperties() + { + Y y = new Y(); + X.SetA(y, 2); + X.SetB(y, "Hi"); + // This test is a bit dodgy, because no guarantees are + // made about the order in which properties and their + // values will be returned + LocalValueEnumerator e = y.GetLocalValueEnumerator(); + Assert.IsTrue(e.MoveNext()); + Assert.AreEqual(e.Current.Property, X.AProperty); + Assert.AreEqual(e.Current.Value, 2); + Assert.IsTrue(e.MoveNext()); + Assert.AreEqual(e.Current.Property, X.BProperty); + Assert.AreEqual(e.Current.Value, "Hi"); + Assert.IsFalse(e.MoveNext()); } // An nice way to test for exceptions the class under test should |