Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/mcs
diff options
context:
space:
mode:
authorIain McCoy <iainmc@mono-cvs.ximian.com>2005-07-18 20:29:06 +0400
committerIain McCoy <iainmc@mono-cvs.ximian.com>2005-07-18 20:29:06 +0400
commitc063abca55521fb1fd7e03ffd98adfc2b4898b12 (patch)
treedd4d0913c9a65e50881a5ced20678fb01736b7ad /mcs
parente58d1ac64815170598fee921f87b7502b3e51bf9 (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')
-rw-r--r--mcs/class/PresentationFramework/ChangeLog6
-rw-r--r--mcs/class/PresentationFramework/Mono.Windows.Serialization/CodeWriter.cs4
-rw-r--r--mcs/class/PresentationFramework/Mono.Windows.Serialization/ObjectWriter.cs4
-rw-r--r--mcs/class/PresentationFramework/Mono.Windows.Serialization/XamlParser.cs10
-rw-r--r--mcs/class/PresentationFramework/Mono.Windows.Serialization/XamlWriter.cs4
-rw-r--r--mcs/class/PresentationFramework/PresentationFramework.dll.sources2
-rw-r--r--mcs/class/PresentationFramework/Test/CodeWriter.cs2
-rw-r--r--mcs/class/PresentationFramework/Test/XamlParser.cs22
-rw-r--r--mcs/class/WindowsBase/ChangeLog9
-rw-r--r--mcs/class/WindowsBase/System.Windows/DependencyObject.cs2
-rw-r--r--mcs/class/WindowsBase/System.Windows/LocalValueEnumerator.cs24
-rw-r--r--mcs/class/WindowsBase/Test/AttachedProperties.cs38
-rw-r--r--mcs/tools/xamlc/ChangeLog5
-rw-r--r--mcs/tools/xamlc/demo/TestVocab/ConsoleApp.cs18
-rw-r--r--mcs/tools/xamlc/demo/TestVocab/ConsoleReader.cs10
-rw-r--r--mcs/tools/xamlc/demo/TestVocab/ConsoleValue.cs20
-rw-r--r--mcs/tools/xamlc/demo/TestVocab/ConsoleWriter.cs10
17 files changed, 153 insertions, 37 deletions
diff --git a/mcs/class/PresentationFramework/ChangeLog b/mcs/class/PresentationFramework/ChangeLog
index dde05e844d3..3540ec9b06d 100644
--- a/mcs/class/PresentationFramework/ChangeLog
+++ b/mcs/class/PresentationFramework/ChangeLog
@@ -1,5 +1,11 @@
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
+
+2005-07-18 Iain McCoy <iain@mccoy.id.au>
+
* Mono.Windows.Serialization/CodeWriter.cs,
Test/CodeWriter.cs
Test/XamlWriter.cs: fix bug with explicitly naming objects in
diff --git a/mcs/class/PresentationFramework/Mono.Windows.Serialization/CodeWriter.cs b/mcs/class/PresentationFramework/Mono.Windows.Serialization/CodeWriter.cs
index e35c8684c54..b7c93d0a492 100644
--- a/mcs/class/PresentationFramework/Mono.Windows.Serialization/CodeWriter.cs
+++ b/mcs/class/PresentationFramework/Mono.Windows.Serialization/CodeWriter.cs
@@ -35,7 +35,7 @@ using System.CodeDom;
using System.CodeDom.Compiler;
namespace Mono.Windows.Serialization {
- public class CodeWriter : XamlWriter {
+ public class CodeWriter : IXamlWriter {
TextWriter writer;
ICodeGenerator generator;
bool isPartial;
@@ -199,7 +199,7 @@ namespace Mono.Windows.Serialization {
}
// top of stack must be an object reference
- public void CreateElementText(string text)
+ public void CreateObjectText(string text)
{
debug();
CodeVariableReferenceExpression var = (CodeVariableReferenceExpression)objects[objects.Count - 1];
diff --git a/mcs/class/PresentationFramework/Mono.Windows.Serialization/ObjectWriter.cs b/mcs/class/PresentationFramework/Mono.Windows.Serialization/ObjectWriter.cs
index 90ceab11270..f8c283cfbfc 100644
--- a/mcs/class/PresentationFramework/Mono.Windows.Serialization/ObjectWriter.cs
+++ b/mcs/class/PresentationFramework/Mono.Windows.Serialization/ObjectWriter.cs
@@ -36,7 +36,7 @@ using System.ComponentModel;
using System.Windows.Serialization;
namespace Mono.Windows.Serialization {
- public class ObjectWriter : XamlWriter {
+ public class ObjectWriter : IXamlWriter {
public object instance;
ArrayList objects = new ArrayList();
@@ -81,7 +81,7 @@ namespace Mono.Windows.Serialization {
setter.Invoke(null, new object[] { objects[objects.Count - 1], value});
}
- public void CreateElementText(string text)
+ public void CreateObjectText(string text)
{
((IAddChild)objects[objects.Count - 1]).AddText(text);
}
diff --git a/mcs/class/PresentationFramework/Mono.Windows.Serialization/XamlParser.cs b/mcs/class/PresentationFramework/Mono.Windows.Serialization/XamlParser.cs
index ad726c84519..0d2d6f4af11 100644
--- a/mcs/class/PresentationFramework/Mono.Windows.Serialization/XamlParser.cs
+++ b/mcs/class/PresentationFramework/Mono.Windows.Serialization/XamlParser.cs
@@ -41,7 +41,7 @@ namespace Mono.Windows.Serialization {
public const string XAML_NAMESPACE = "http://schemas.microsoft.com/winfx/xaml/2005";
private Mapper mapper = new Mapper(new string[] { });
private XmlReader reader;
- private XamlWriter writer;
+ private IXamlWriter writer;
private enum CurrentType { Object,
Property,
@@ -59,17 +59,17 @@ namespace Mono.Windows.Serialization {
private ParserState currentState = null;
private ArrayList oldStates = new ArrayList();
- public XamlParser(string filename, XamlWriter writer) : this(
+ public XamlParser(string filename, IXamlWriter writer) : this(
new XmlTextReader(filename), writer)
{
}
- public XamlParser(TextReader reader, XamlWriter writer) : this(
+ public XamlParser(TextReader reader, IXamlWriter writer) : this(
new XmlTextReader(reader), writer)
{
}
- public XamlParser(XmlReader reader, XamlWriter writer)
+ public XamlParser(XmlReader reader, IXamlWriter writer)
{
this.reader = reader;
this.writer = writer;
@@ -201,7 +201,7 @@ namespace Mono.Windows.Serialization {
case CurrentType.Object:
case CurrentType.PropertyObject:
abortIfNotAddChild("text");
- writer.CreateElementText(reader.Value);
+ writer.CreateObjectText(reader.Value);
break;
case CurrentType.DependencyProperty:
DependencyProperty dp = (DependencyProperty)currentState.obj;
diff --git a/mcs/class/PresentationFramework/Mono.Windows.Serialization/XamlWriter.cs b/mcs/class/PresentationFramework/Mono.Windows.Serialization/XamlWriter.cs
index 5de3c224985..1a3869a703a 100644
--- a/mcs/class/PresentationFramework/Mono.Windows.Serialization/XamlWriter.cs
+++ b/mcs/class/PresentationFramework/Mono.Windows.Serialization/XamlWriter.cs
@@ -30,11 +30,11 @@ using System;
using System.Reflection;
namespace Mono.Windows.Serialization {
- public interface XamlWriter {
+ public interface IXamlWriter {
void CreateTopLevel(Type parent, string className);
void CreateObject(Type type, string name);
- void CreateElementText(string text);
+ void CreateObjectText(string text);
void EndObject();
void CreateProperty(PropertyInfo property);
diff --git a/mcs/class/PresentationFramework/PresentationFramework.dll.sources b/mcs/class/PresentationFramework/PresentationFramework.dll.sources
index a39ed38938a..d3db2b1a460 100644
--- a/mcs/class/PresentationFramework/PresentationFramework.dll.sources
+++ b/mcs/class/PresentationFramework/PresentationFramework.dll.sources
@@ -5,5 +5,5 @@ Mono.Windows.Serialization/CodeWriter.cs
Mono.Windows.Serialization/ObjectWriter.cs
Mono.Windows.Serialization/Exceptions.cs
Mono.Windows.Serialization/XamlParser.cs
-Mono.Windows.Serialization/XamlWriter.cs
+Mono.Windows.Serialization/IXamlWriter.cs
Assembly/AssemblyInfo.cs
diff --git a/mcs/class/PresentationFramework/Test/CodeWriter.cs b/mcs/class/PresentationFramework/Test/CodeWriter.cs
index 2554fd28b78..976f288981c 100644
--- a/mcs/class/PresentationFramework/Test/CodeWriter.cs
+++ b/mcs/class/PresentationFramework/Test/CodeWriter.cs
@@ -152,7 +152,7 @@ public class CodeWriterTest {
{
cw.CreateTopLevel(typeof(ConsoleApp), null);
cw.CreateObject(typeof(ConsoleWriter), null);
- cw.CreateElementText("Hello");
+ cw.CreateObjectText("Hello");
cw.EndObject();
cw.EndObject();
cw.Finish();
diff --git a/mcs/class/PresentationFramework/Test/XamlParser.cs b/mcs/class/PresentationFramework/Test/XamlParser.cs
index 8e77a3df458..13e497f5dcf 100644
--- a/mcs/class/PresentationFramework/Test/XamlParser.cs
+++ b/mcs/class/PresentationFramework/Test/XamlParser.cs
@@ -34,9 +34,9 @@
// tells the code generator to do what you'd expect. This tests both the parsing
// and type-checking bits of XamlParser.
//
-// The various Happening classes each represent methods on the XamlWriter
+// The various Happening classes each represent methods on the IXamlWriter
// interface that XamlParser could call. The constructor of a Happening takes
-// the same arguments as the XamlWriter method it represents, and merely stashes
+// the same arguments as the IXamlWriter method it represents, and merely stashes
// those values in the suitable public fields.
//
// The ParserTester class takes a Xaml document and a list of Happenings, and
@@ -203,7 +203,7 @@ public class XamlParserTest : Assertion {
ParserTester pt = new ParserTester(MAPPING + s,
new CreateTopLevelHappening(typeof(ConsoleApp), null),
new CreateObjectHappening(typeof(ConsoleWriter), null),
- new CreateElementTextHappening("Hello"),
+ new CreateObjectTextHappening("Hello"),
new EndObjectHappening(),
new EndObjectHappening(),
new FinishHappening());
@@ -442,7 +442,7 @@ public class XamlParserTest : Assertion {
ParserTester pt = new ParserTester(MAPPING + s,
new CreateTopLevelHappening(typeof(ConsoleApp), null),
new CreateObjectHappening(typeof(ConsoleValueString), null),
- new CreateElementTextHappening("xyz"),
+ new CreateObjectTextHappening("xyz"),
new EndObjectHappening(),
new EndObjectHappening(),
new EndObjectHappening(),
@@ -477,10 +477,10 @@ class CreateObjectHappening : Happening
}
}
-class CreateElementTextHappening : Happening
+class CreateObjectTextHappening : Happening
{
public string text;
- public CreateElementTextHappening(string text) {
+ public CreateObjectTextHappening(string text) {
this.text = text;
}
}
@@ -580,7 +580,7 @@ class FinishHappening : Happening
}
-class ParserTester : XamlWriter {
+class ParserTester : IXamlWriter {
string document;
Happening[] happenings;
int c;
@@ -640,11 +640,11 @@ class ParserTester : XamlWriter {
Assert.AreEqual(h.objectName, objectName);
}
- public void CreateElementText(string text){
- d("CreateElementText");
- AssertSubclass(typeof(CreateElementTextHappening), false);
+ public void CreateObjectText(string text){
+ d("CreateObjectText");
+ AssertSubclass(typeof(CreateObjectTextHappening), false);
- CreateElementTextHappening h = (CreateElementTextHappening)getHappening();
+ CreateObjectTextHappening h = (CreateObjectTextHappening)getHappening();
Assert.AreEqual(h.text, text);
}
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
diff --git a/mcs/tools/xamlc/ChangeLog b/mcs/tools/xamlc/ChangeLog
index 8ccbe1d0dd7..b576ef9001f 100644
--- a/mcs/tools/xamlc/ChangeLog
+++ b/mcs/tools/xamlc/ChangeLog
@@ -1,5 +1,10 @@
2005-07-18 Iain McCoy <iain@mccoy.id.au>
+ * demo/TestVocab/*.cs: add implementations of equals so that tests for
+ the ObjectWriter can be written.
+
+2005-07-18 Iain McCoy <iain@mccoy.id.au>
+
* demo/runtimetest.xaml: added testing of complex objects as property
values
diff --git a/mcs/tools/xamlc/demo/TestVocab/ConsoleApp.cs b/mcs/tools/xamlc/demo/TestVocab/ConsoleApp.cs
index 62412218c2c..e6cf9a2a160 100644
--- a/mcs/tools/xamlc/demo/TestVocab/ConsoleApp.cs
+++ b/mcs/tools/xamlc/demo/TestVocab/ConsoleApp.cs
@@ -47,5 +47,23 @@ namespace Xaml.TestVocab.Console {
{
return (int)obj.GetValue(RepetitionsProperty);
}
+
+ public override bool Equals(object o)
+ {
+ ConsoleApp app = (ConsoleApp)o;
+ if (app.actions.Count != actions.Count)
+ return false;
+ if (app.SomethingHappened != SomethingHappened)
+ return false;
+
+ for (int i = 0; i < actions.Count; i++)
+ if (!actions[i].Equals(app.actions[i]))
+ return false;
+ return true;
+ }
+ public override int GetHashCode()
+ {
+ return actions.GetHashCode();
+ }
}
}
diff --git a/mcs/tools/xamlc/demo/TestVocab/ConsoleReader.cs b/mcs/tools/xamlc/demo/TestVocab/ConsoleReader.cs
index 89da77e616d..f0551beae28 100644
--- a/mcs/tools/xamlc/demo/TestVocab/ConsoleReader.cs
+++ b/mcs/tools/xamlc/demo/TestVocab/ConsoleReader.cs
@@ -20,5 +20,15 @@ namespace Xaml.TestVocab.Console {
string s = System.Console.ReadLine();
ConsoleVars.Set(variable, s);
}
+
+ public override bool Equals(object o)
+ {
+ ConsoleReader reader = (ConsoleReader)o;
+ return (reader.variable == variable) && (reader.prompt == prompt);
+ }
+ public override int GetHashCode()
+ {
+ return variable.GetHashCode() + prompt.GetHashCode();
+ }
}
}
diff --git a/mcs/tools/xamlc/demo/TestVocab/ConsoleValue.cs b/mcs/tools/xamlc/demo/TestVocab/ConsoleValue.cs
index 22929673097..e0b5870f1bb 100644
--- a/mcs/tools/xamlc/demo/TestVocab/ConsoleValue.cs
+++ b/mcs/tools/xamlc/demo/TestVocab/ConsoleValue.cs
@@ -8,6 +8,16 @@ namespace Xaml.TestVocab.Console {
[TypeConverter(typeof(ConsoleValueConverter))]
public abstract class ConsoleValue {
public abstract string Value { get; }
+
+
+ public override bool Equals(Object o)
+ {
+ return (((ConsoleValue)o).Value == Value);
+ }
+ public override int GetHashCode()
+ {
+ return Value.GetHashCode();
+ }
}
public class ConsoleValueConverter : TypeConverter {
@@ -50,6 +60,7 @@ namespace Xaml.TestVocab.Console {
public override string Value {
get { return val; }
}
+
}
public class ConsoleValueAppend : ConsoleValue {
@@ -85,6 +96,15 @@ namespace Xaml.TestVocab.Console {
get { return var; }
set { var = value; }
}
+
+ public override bool Equals(object o)
+ {
+ return (((ConsoleValueVar)o).var == var);
+ }
+ public override int GetHashCode()
+ {
+ return var.GetHashCode();
+ }
}
}
diff --git a/mcs/tools/xamlc/demo/TestVocab/ConsoleWriter.cs b/mcs/tools/xamlc/demo/TestVocab/ConsoleWriter.cs
index 465b78c36e9..109e1b195ae 100644
--- a/mcs/tools/xamlc/demo/TestVocab/ConsoleWriter.cs
+++ b/mcs/tools/xamlc/demo/TestVocab/ConsoleWriter.cs
@@ -48,5 +48,15 @@ namespace Xaml.TestVocab.Console {
s = f(s);
System.Console.WriteLine(s);
}
+
+ public override bool Equals(object o)
+ {
+ ConsoleWriter writer = (ConsoleWriter)o;
+ return (writer.filter == filter) && (writer.text == text);
+ }
+ public override int GetHashCode()
+ {
+ return filter.GetHashCode() + text.GetHashCode();
+ }
}
}