2005-08-26 Iain McCoy <iain@mccoy.id.au>
authorIain McCoy <iainmc@mono-cvs.ximian.com>
Fri, 26 Aug 2005 11:15:34 +0000 (11:15 -0000)
committerIain McCoy <iainmc@mono-cvs.ximian.com>
Fri, 26 Aug 2005 11:15:34 +0000 (11:15 -0000)
        * demo/runtimetest.cs: use the newly-renamed Parser class instead of
        the interim ObjectWriter

2005-08-24  Iain McCoy  <iain@mccoy.id.au>

        * Mono.Windows.Serialization/ObjectWriter.cs,
        System.Windows.Serialization/Parser.cs: renamed ObjectWriter to
        Parser, made interface more similar
        * Test/ObjectWriter.cs: changed to test the new Parser class

2005-08-24  Iain McCoy  <iain@mccoy.id.au>

        * Mono.Windows.Serialization/XamlParser.cs: make internal
        * Mono.Windows.Serialization/CodeWriter.cs: add private member so that
        the tests can get at the type for XamlParser
        * Test/XamlParser.cs: use reflection to get the XamlParser type out of
        CodeWriter, create an instance of it and get nodes from it

svn path=/trunk/mcs/; revision=48885

1  2 
mcs/class/PresentationFramework/ChangeLog
mcs/class/PresentationFramework/Mono.Windows.Serialization/CodeWriter.cs
mcs/class/PresentationFramework/Mono.Windows.Serialization/ObjectWriter.cs
mcs/class/PresentationFramework/Mono.Windows.Serialization/XamlParser.cs
mcs/class/PresentationFramework/PresentationFramework.dll.sources
mcs/class/PresentationFramework/System.Windows.Serialization/Parser.cs
mcs/class/PresentationFramework/Test/ObjectWriter.cs
mcs/class/PresentationFramework/Test/XamlParser.cs
mcs/tools/xamlc/ChangeLog
mcs/tools/xamlc/demo/runtimetest.cs

index 77bc2be83da5bc37a3c5260f77082c0fb277fdbf,77bc2be83da5bc37a3c5260f77082c0fb277fdbf..4e73cfed51d528283dd229cb41e54eaed8ff9f7a
@@@ -1,3 -1,3 +1,18 @@@
++2005-08-24  Iain McCoy  <iain@mccoy.id.au>
++
++      * Mono.Windows.Serialization/ObjectWriter.cs,
++      System.Windows.Serialization/Parser.cs: renamed ObjectWriter to
++      Parser, made interface more similar
++      * Test/ObjectWriter.cs: changed to test the new Parser class
++
++2005-08-24  Iain McCoy  <iain@mccoy.id.au>
++
++      * Mono.Windows.Serialization/XamlParser.cs: make internal
++      * Mono.Windows.Serialization/CodeWriter.cs: add private member so that
++      the tests can get at the type for XamlParser
++      * Test/XamlParser.cs: use reflection to get the XamlParser type out of
++      CodeWriter, create an instance of it and get nodes from it
++
  2005-08-23  Iain McCoy  <iain@mccoy.id.au>
  
        * System.Windows.Serialization/XamlParser.cs: rearrange class so that
index 244c321857c07018abf79b131f6350020dac0479,244c321857c07018abf79b131f6350020dac0479..cf34fe2098a9e7162a14a4ec99a82f8d0e04f62b
@@@ -51,6 -51,6 +51,8 @@@ namespace Mono.Windows.Serialization 
                CodeTypeDeclaration type;
                CodeConstructor constructor;
  
++              private static readonly Type xamlParserType = typeof(XamlParser);
++
                public static string Parse(XmlTextReader reader, ICodeGenerator generator,  bool isPartial)
                {
                        CodeWriter cw = new CodeWriter(reader, generator, isPartial);
diff --cc mcs/class/PresentationFramework/Mono.Windows.Serialization/ObjectWriter.cs
index c078cb0763ef5b8b98e9ef9ca667ba8b17454592,c078cb0763ef5b8b98e9ef9ca667ba8b17454592..0000000000000000000000000000000000000000
deleted file mode 100644,100644
+++ /dev/null
@@@ -1,270 -1,270 +1,0 @@@
--//
--// CodeWriter.cs
--//
--// Author:
--//   Iain McCoy (iain@mccoy.id.au)
--//
--// (C) 2005 Iain McCoy
--//
--// Permission is hereby granted, free of charge, to any person obtaining
--// a copy of this software and associated documentation files (the
--// "Software"), to deal in the Software without restriction, including
--// without limitation the rights to use, copy, modify, merge, publish,
--// distribute, sublicense, and/or sell copies of the Software, and to
--// permit persons to whom the Software is furnished to do so, subject to
--// the following conditions:
--// 
--// The above copyright notice and this permission notice shall be
--// included in all copies or substantial portions of the Software.
--// 
--// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
--// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
--// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
--// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
--// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
--// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
--// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--//
--
--using System;
--using System.Reflection;
--using System.IO;
--using System.Collections;
--using System.CodeDom;
--using System.CodeDom.Compiler;
--using System.ComponentModel;
--using System.Diagnostics;
--using System.Windows;
--using System.Windows.Serialization;
--using System.Xml;
--
--namespace Mono.Windows.Serialization {
--      public class ObjectWriter {
--              public object instance;
--              ArrayList objects = new ArrayList();
--
--              public static object Parse(XmlTextReader reader)
--              {
--                      ObjectWriter ow = new ObjectWriter(reader);
--                      return ow.instance;
--              }
--              private ObjectWriter(XmlTextReader reader)
--              {
--                      XamlParser p = new XamlParser(reader);
--                      XamlNode n;
--                      while (true) {
--                              n = p.GetNextNode();
--                              if (n == null)
--                                      break;
--                              Debug.WriteLine("ObjectWriter: INCOMING " + n.GetType());
--                              if (n is XamlDocumentStartNode) {
--                                      Debug.WriteLine("ObjectWriter: document begins");
--                                      // do nothing
--                              } else if (n is XamlElementStartNode && n.Depth == 0) {
--                                      Debug.WriteLine("ObjectWriter: element begins as top-level");
--                                      CreateTopLevel(((XamlElementStartNode)n).ElementType, ((XamlElementStartNode)n).name);
--                              } else if (n is XamlElementStartNode && peek() is PropertyInfo) {
--                                      Debug.WriteLine("ObjectWriter: element begins as property value");
--                                      CreatePropertyObject(((XamlElementStartNode)n).ElementType, ((XamlElementStartNode)n).name);
--                              } else if (n is XamlElementStartNode) {
--                                      Debug.WriteLine("ObjectWriter: element begins");
--                                      CreateObject(((XamlElementStartNode)n).ElementType, ((XamlElementStartNode)n).name);
--                              } else if (n is XamlPropertyNode && ((XamlPropertyNode)n).PropInfo != null) {
--                                      Debug.WriteLine("ObjectWriter: normal property begins");
--                                      CreateProperty(((XamlPropertyNode)n).PropInfo);
--                              } else if (n is XamlPropertyNode && ((XamlPropertyNode)n).DP != null) {
--                                      Debug.WriteLine("ObjectWriter: dependency property begins");
--                                      DependencyProperty dp = ((XamlPropertyNode)n).DP;
--                                      Type typeAttachedTo = dp.OwnerType;
--                                      string propertyName = ((XamlPropertyNode)n).PropertyName;
--                                      
--                                      CreateDependencyProperty(typeAttachedTo, propertyName, dp.PropertyType);
--                              } else if (n is XamlClrEventNode) {
--                                      Debug.WriteLine("ObjectWriter: event");
--                                      CreateEvent((EventInfo)((XamlClrEventNode)n).EventMember);
--                                      CreateEventDelegate(((XamlClrEventNode)n).Value, ((EventInfo)((XamlClrEventNode)n).EventMember).EventHandlerType);
--                                      EndEvent();
--
--                              } else if (n is XamlTextNode && ((XamlTextNode)n).mode == XamlParseMode.Object){
--                                      Debug.WriteLine("ObjectWriter: text for object");
--                                      CreateObjectText(((XamlTextNode)n).TextContent);
--                              } else if (n is XamlTextNode && ((XamlTextNode)n).mode == XamlParseMode.Property){
--                                      Debug.WriteLine("ObjectWriter: text for property");
--                                      Debug.WriteLine("THINGTYPE = " + peek().GetType());
--                                      CreatePropertyText(((XamlTextNode)n).TextContent, ((PropertyInfo)peek()).PropertyType);
--                                      EndProperty();
--                              } else if (n is XamlTextNode && ((XamlTextNode)n).mode == XamlParseMode.DependencyProperty){
--                                      Debug.WriteLine("ObjectWriter: text for dependency property");
--                                      string propertyName = (string)peek();
--                                      Type attachedTo = (Type)peek(1);
--                                      CreateDependencyPropertyText(((XamlTextNode)n).TextContent, ((DependencyProperty)attachedTo.GetField(propertyName + "Property").GetValue(null)).PropertyType);
--                                      EndDependencyProperty();
--                              } else if (n is XamlPropertyComplexEndNode) {
--                                      Debug.WriteLine("ObjectWriter: end complex property");
--                                      Debug.WriteLine("ObjectWriter: final type is " + ((XamlPropertyComplexEndNode)n).finalType);
--                                      EndPropertyObject(((XamlPropertyComplexEndNode)n).finalType);
--                                      EndProperty();
--                              } else if (n is XamlElementEndNode) {
--                                      Debug.WriteLine("ObjectWriter: end element");
--                                      if (!((XamlElementEndNode)n).propertyObject)
--                                              EndObject();
--                              } else if (n is XamlDocumentEndNode) {
--                                      Debug.WriteLine("ObjectWriter: end document");
--                                      Finish();
--                              } else {
--                                      throw new Exception("Unknown node " + n.GetType());
--                              }
--                      }
--              }
--
--      
--              public void CreateTopLevel(Type parent, string className)
--              {
--                      instance = Activator.CreateInstance(parent);
--                      push(instance);
--              }
--
--              public void CreateObject(Type type, string varName)
--              {
--                      Object o = Activator.CreateInstance(type);
--                      ((IAddChild)peek()).AddChild(o);
--                      push(o);
--              }
--
--              public void CreateProperty(PropertyInfo property)
--              {
--                      push(property);
--              }
--
--              // top of stack is a reference to an object
--              // pushes a reference to the event
--              public void CreateEvent(EventInfo evt)
--              {
--                      push(evt);
--              }
--
--              public void CreateDependencyProperty(Type attachedTo, string propertyName, Type propertyType)
--              {
--                      push(attachedTo);
--                      push(propertyName);
--              }
--
--              public void EndDependencyProperty()
--              {
--                      object value = pop();
--                      string propertyName = (string)pop();
--                      Type attachedTo = (Type)pop();
--
--                      MethodInfo setter = attachedTo.GetMethod("Set" + propertyName);
--                      setter.Invoke(null, new object[] { peek(), value});
--              }
--
--              public void CreateObjectText(string text)
--              {
--                      ((IAddChild)peek()).AddText(text);
--              }
--
--              // top of stack is reference to an event
--              public void CreateEventDelegate(string functionName, Type eventDelegateType)
--              {
--                      EventInfo e = (EventInfo)peek();
--                      object o = peek(1);
--                      e.AddEventHandler(o, Delegate.CreateDelegate(o.GetType(), o, functionName));
--              }
--              // top of stack is reference to a property
--              public void CreatePropertyDelegate(string functionName, Type propertyType)
--              {
--                      PropertyInfo p = (PropertyInfo)peek();
--                      object o = peek(1);
--                      p.SetValue(o, Delegate.CreateDelegate(o.GetType(), o, functionName), null);
--              }
--
--              public void CreatePropertyText(string text, Type propertyType)
--              {
--                      object value = text;
--                      if (propertyType != typeof(string)) {
--                              TypeConverter tc = TypeDescriptor.GetConverter(propertyType);
--                              value = tc.ConvertFromString(text);
--                      }
--                      PropertyInfo p = (PropertyInfo)peek();
--                      object o = peek(1);
--                      p.SetValue(o, value, null);
--              }
--              
--              public void CreatePropertyObject(Type type, string name)
--              {
--                      object value = Activator.CreateInstance(type);
--                      Debug.WriteLine("ObjectWriter CREATING PROPERTY OBJECT of type" + type);
--                      push(value);
--              }
--              public void EndPropertyObject(Type destType)
--              {
--                      object value = pop();
--                      Type sourceType = value.GetType();
--                      Debug.WriteLine("ObjectWriter: EndPropertyObject has a " + value + value.GetType() + ", needs a " + destType);
--                      if (destType != sourceType && !sourceType.IsSubclassOf(destType)) {
--                              TypeConverter tc = TypeDescriptor.GetConverter(destType);
--                              value = tc.ConvertFrom(value);
--                      }
--                      PropertyInfo p = (PropertyInfo)peek();
--                      object o = peek(1);
--                      p.SetValue(o, value, null);
--              }
--
--              // top of stack is reference to an attached property
--              public void CreateDependencyPropertyText(string text, Type propertyType)
--              {
--                      object value = text;
--                      if (propertyType != typeof(string)) {
--                              TypeConverter tc = TypeDescriptor.GetConverter(propertyType);
--                              value = tc.ConvertFromString(text);
--                      }
--                      push(value);
--              }
--              
--              public void EndObject()
--              {
--                      pop();
--              }
--
--              public void EndProperty()
--              {
--                      pop();
--              }
--              
--              public void EndEvent()
--              {
--                      pop();
--              }
--
--              public void Finish()
--              {
--              }
--
--              public void CreateCode(string code)
--              {
--                      throw new NotImplementedException();
--              }
--
--              private object peek()
--              {
--                      return peek(0);
--              }
--              private object peek(int i)
--              {
--                      return objects[objects.Count - 1 - i];
--              }
--              private object pop()
--              {
--                      object v = objects[objects.Count - 1];
--                      objects.RemoveAt(objects.Count - 1);
--                      Debug.WriteLine("ObjectWriter POPPING");
--                      return v;
--              }
--              private void push(object v)
--              {
--                      Debug.WriteLine("ObjectWriter PUSHING " + v);
--                      objects.Add(v);
--              }
--      }
--}
index 4a96b7e24829417c264877d96c02ca99f72b5d21,4a96b7e24829417c264877d96c02ca99f72b5d21..b7702f792d50177f7b847e94074325d101956b11
@@@ -37,7 -37,7 +37,7 @@@ using System.Windows
  using System.Windows.Serialization;
  
  namespace Mono.Windows.Serialization {
--      public class XamlParser {
++      internal class XamlParser {
                public const string XAML_NAMESPACE = "http://schemas.microsoft.com/winfx/xaml/2005";
                private Mapper mapper = new Mapper(new string[] { });
                private XmlTextReader reader;
index 796cdc5ace64a573f1452dbfe0b76f455e8ef9d8,796cdc5ace64a573f1452dbfe0b76f455e8ef9d8..a76d924c5b29047c07c3749297edddd27ecb9dee
@@@ -1,11 -1,11 +1,11 @@@
  System.Windows.Serialization/IAddChild.cs
  System.Windows.Serialization/Mapper.cs
  System.Windows.Serialization/NamespaceMapEntry.cs
++System.Windows.Serialization/Parser.cs
  System.Windows.Serialization/XamlNodeType.cs
  System.Windows.Serialization/XamlParseMode.cs
  System.Windows.Serialization/BamlAttributeUsage.cs
  Mono.Windows.Serialization/CodeWriter.cs
--Mono.Windows.Serialization/ObjectWriter.cs
  Mono.Windows.Serialization/Exceptions.cs
  Mono.Windows.Serialization/XamlParser.cs
  Mono.Windows.Serialization/IXamlWriter.cs
index 0000000000000000000000000000000000000000,0000000000000000000000000000000000000000..3b50d5c8dd2fcb2f66702fa7ad8915ff4d353dd5
new file mode 100644 (file)
--- /dev/null
--- /dev/null
@@@ -1,0 -1,0 +1,275 @@@
++//
++// CodeWriter.cs
++//
++// Author:
++//   Iain McCoy (iain@mccoy.id.au)
++//
++// (C) 2005 Iain McCoy
++//
++// Permission is hereby granted, free of charge, to any person obtaining
++// a copy of this software and associated documentation files (the
++// "Software"), to deal in the Software without restriction, including
++// without limitation the rights to use, copy, modify, merge, publish,
++// distribute, sublicense, and/or sell copies of the Software, and to
++// permit persons to whom the Software is furnished to do so, subject to
++// the following conditions:
++// 
++// The above copyright notice and this permission notice shall be
++// included in all copies or substantial portions of the Software.
++// 
++// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
++// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
++// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
++// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
++// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++//
++
++using System;
++using System.Reflection;
++using System.IO;
++using System.Collections;
++using System.CodeDom;
++using System.CodeDom.Compiler;
++using System.ComponentModel;
++using System.Diagnostics;
++using System.Windows;
++using Mono.Windows.Serialization;
++using System.Xml;
++
++namespace System.Windows.Serialization {
++      public class Parser {
++              private object instance;
++              ArrayList objects = new ArrayList();
++
++              public static object LoadXml(Stream s)
++              {
++                      return LoadXml(new XmlTextReader(s));
++              }
++              // TODO: this should take a XmlReader in order to be same as MSFT
++              public static object LoadXml(XmlTextReader reader)
++              {
++                      Parser r = new Parser(reader);
++                      return r.instance;
++              }
++              private Parser(XmlTextReader reader)
++              {
++                      XamlParser p = new XamlParser(reader);
++                      XamlNode n;
++                      while (true) {
++                              n = p.GetNextNode();
++                              if (n == null)
++                                      break;
++                              Debug.WriteLine("ObjectWriter: INCOMING " + n.GetType());
++                              if (n is XamlDocumentStartNode) {
++                                      Debug.WriteLine("ObjectWriter: document begins");
++                                      // do nothing
++                              } else if (n is XamlElementStartNode && n.Depth == 0) {
++                                      Debug.WriteLine("ObjectWriter: element begins as top-level");
++                                      CreateTopLevel(((XamlElementStartNode)n).ElementType, ((XamlElementStartNode)n).name);
++                              } else if (n is XamlElementStartNode && peek() is PropertyInfo) {
++                                      Debug.WriteLine("ObjectWriter: element begins as property value");
++                                      CreatePropertyObject(((XamlElementStartNode)n).ElementType, ((XamlElementStartNode)n).name);
++                              } else if (n is XamlElementStartNode) {
++                                      Debug.WriteLine("ObjectWriter: element begins");
++                                      CreateObject(((XamlElementStartNode)n).ElementType, ((XamlElementStartNode)n).name);
++                              } else if (n is XamlPropertyNode && ((XamlPropertyNode)n).PropInfo != null) {
++                                      Debug.WriteLine("ObjectWriter: normal property begins");
++                                      CreateProperty(((XamlPropertyNode)n).PropInfo);
++                              } else if (n is XamlPropertyNode && ((XamlPropertyNode)n).DP != null) {
++                                      Debug.WriteLine("ObjectWriter: dependency property begins");
++                                      DependencyProperty dp = ((XamlPropertyNode)n).DP;
++                                      Type typeAttachedTo = dp.OwnerType;
++                                      string propertyName = ((XamlPropertyNode)n).PropertyName;
++                                      
++                                      CreateDependencyProperty(typeAttachedTo, propertyName, dp.PropertyType);
++                              } else if (n is XamlClrEventNode) {
++                                      Debug.WriteLine("ObjectWriter: event");
++                                      CreateEvent((EventInfo)((XamlClrEventNode)n).EventMember);
++                                      CreateEventDelegate(((XamlClrEventNode)n).Value, ((EventInfo)((XamlClrEventNode)n).EventMember).EventHandlerType);
++                                      EndEvent();
++
++                              } else if (n is XamlTextNode && ((XamlTextNode)n).mode == XamlParseMode.Object){
++                                      Debug.WriteLine("ObjectWriter: text for object");
++                                      CreateObjectText(((XamlTextNode)n).TextContent);
++                              } else if (n is XamlTextNode && ((XamlTextNode)n).mode == XamlParseMode.Property){
++                                      Debug.WriteLine("ObjectWriter: text for property");
++                                      Debug.WriteLine("THINGTYPE = " + peek().GetType());
++                                      CreatePropertyText(((XamlTextNode)n).TextContent, ((PropertyInfo)peek()).PropertyType);
++                                      EndProperty();
++                              } else if (n is XamlTextNode && ((XamlTextNode)n).mode == XamlParseMode.DependencyProperty){
++                                      Debug.WriteLine("ObjectWriter: text for dependency property");
++                                      string propertyName = (string)peek();
++                                      Type attachedTo = (Type)peek(1);
++                                      CreateDependencyPropertyText(((XamlTextNode)n).TextContent, ((DependencyProperty)attachedTo.GetField(propertyName + "Property").GetValue(null)).PropertyType);
++                                      EndDependencyProperty();
++                              } else if (n is XamlPropertyComplexEndNode) {
++                                      Debug.WriteLine("ObjectWriter: end complex property");
++                                      Debug.WriteLine("ObjectWriter: final type is " + ((XamlPropertyComplexEndNode)n).finalType);
++                                      EndPropertyObject(((XamlPropertyComplexEndNode)n).finalType);
++                                      EndProperty();
++                              } else if (n is XamlElementEndNode) {
++                                      Debug.WriteLine("ObjectWriter: end element");
++                                      if (!((XamlElementEndNode)n).propertyObject)
++                                              EndObject();
++                              } else if (n is XamlDocumentEndNode) {
++                                      Debug.WriteLine("ObjectWriter: end document");
++                                      Finish();
++                              } else {
++                                      throw new Exception("Unknown node " + n.GetType());
++                              }
++                      }
++              }
++
++      
++              public void CreateTopLevel(Type parent, string className)
++              {
++                      instance = Activator.CreateInstance(parent);
++                      push(instance);
++              }
++
++              public void CreateObject(Type type, string varName)
++              {
++                      Object o = Activator.CreateInstance(type);
++                      ((IAddChild)peek()).AddChild(o);
++                      push(o);
++              }
++
++              public void CreateProperty(PropertyInfo property)
++              {
++                      push(property);
++              }
++
++              // top of stack is a reference to an object
++              // pushes a reference to the event
++              public void CreateEvent(EventInfo evt)
++              {
++                      push(evt);
++              }
++
++              public void CreateDependencyProperty(Type attachedTo, string propertyName, Type propertyType)
++              {
++                      push(attachedTo);
++                      push(propertyName);
++              }
++
++              public void EndDependencyProperty()
++              {
++                      object value = pop();
++                      string propertyName = (string)pop();
++                      Type attachedTo = (Type)pop();
++
++                      MethodInfo setter = attachedTo.GetMethod("Set" + propertyName);
++                      setter.Invoke(null, new object[] { peek(), value});
++              }
++
++              public void CreateObjectText(string text)
++              {
++                      ((IAddChild)peek()).AddText(text);
++              }
++
++              // top of stack is reference to an event
++              public void CreateEventDelegate(string functionName, Type eventDelegateType)
++              {
++                      EventInfo e = (EventInfo)peek();
++                      object o = peek(1);
++                      e.AddEventHandler(o, Delegate.CreateDelegate(o.GetType(), o, functionName));
++              }
++              // top of stack is reference to a property
++              public void CreatePropertyDelegate(string functionName, Type propertyType)
++              {
++                      PropertyInfo p = (PropertyInfo)peek();
++                      object o = peek(1);
++                      p.SetValue(o, Delegate.CreateDelegate(o.GetType(), o, functionName), null);
++              }
++
++              public void CreatePropertyText(string text, Type propertyType)
++              {
++                      object value = text;
++                      if (propertyType != typeof(string)) {
++                              TypeConverter tc = TypeDescriptor.GetConverter(propertyType);
++                              value = tc.ConvertFromString(text);
++                      }
++                      PropertyInfo p = (PropertyInfo)peek();
++                      object o = peek(1);
++                      p.SetValue(o, value, null);
++              }
++              
++              public void CreatePropertyObject(Type type, string name)
++              {
++                      object value = Activator.CreateInstance(type);
++                      Debug.WriteLine("ObjectWriter CREATING PROPERTY OBJECT of type" + type);
++                      push(value);
++              }
++              public void EndPropertyObject(Type destType)
++              {
++                      object value = pop();
++                      Type sourceType = value.GetType();
++                      Debug.WriteLine("ObjectWriter: EndPropertyObject has a " + value + value.GetType() + ", needs a " + destType);
++                      if (destType != sourceType && !sourceType.IsSubclassOf(destType)) {
++                              TypeConverter tc = TypeDescriptor.GetConverter(destType);
++                              value = tc.ConvertFrom(value);
++                      }
++                      PropertyInfo p = (PropertyInfo)peek();
++                      object o = peek(1);
++                      p.SetValue(o, value, null);
++              }
++
++              // top of stack is reference to an attached property
++              public void CreateDependencyPropertyText(string text, Type propertyType)
++              {
++                      object value = text;
++                      if (propertyType != typeof(string)) {
++                              TypeConverter tc = TypeDescriptor.GetConverter(propertyType);
++                              value = tc.ConvertFromString(text);
++                      }
++                      push(value);
++              }
++              
++              public void EndObject()
++              {
++                      pop();
++              }
++
++              public void EndProperty()
++              {
++                      pop();
++              }
++              
++              public void EndEvent()
++              {
++                      pop();
++              }
++
++              public void Finish()
++              {
++              }
++
++              public void CreateCode(string code)
++              {
++                      throw new NotImplementedException();
++              }
++
++              private object peek()
++              {
++                      return peek(0);
++              }
++              private object peek(int i)
++              {
++                      return objects[objects.Count - 1 - i];
++              }
++              private object pop()
++              {
++                      object v = objects[objects.Count - 1];
++                      objects.RemoveAt(objects.Count - 1);
++                      Debug.WriteLine("ObjectWriter POPPING");
++                      return v;
++              }
++              private void push(object v)
++              {
++                      Debug.WriteLine("ObjectWriter PUSHING " + v);
++                      objects.Add(v);
++              }
++      }
++}
index 73618b8c251e09b809e980b027d12a1fe1e591c0,73618b8c251e09b809e980b027d12a1fe1e591c0..887ae575d4fafef7d98d0c35a089fb00b354cf33
@@@ -1,5 -1,5 +1,5 @@@
  // 
--// ObjectWriter.cs - NUnit Test Cases for the xaml object builder
++// Parser.cs - NUnit Test Cases for the xaml object builder
  // 
  // Author:
  //   Iain McCoy (iain@mccoy.id.au)
@@@ -37,13 -37,13 +37,14 @@@ using System.Reflection
  using System.Windows;
  using System.CodeDom.Compiler;
  using Mono.Windows.Serialization;
++using System.Windows.Serialization;
  using Xaml.TestVocab.Console;
  
  namespace MonoTests.System.Windows.Serialization
  {
  
  [TestFixture]
--public class ObjectWriterTest {
++public class ParserTest {
        string code;
        
        [SetUp]
        private void compare(object expected)
        {
                string mapping = "<?Mapping ClrNamespace=\"Xaml.TestVocab.Console\" Assembly=\"./TestVocab.dll\" XmlNamespace=\"console\" ?>\n";
--              object o = ObjectWriter.Parse(new XmlTextReader(new StringReader(mapping + code)));
++              object o = Parser.LoadXml(new XmlTextReader(new StringReader(mapping + code)));
                Assert.AreEqual(expected, o);
        }
  
index d70bce4e17f5b4fb0821755098d040a52e3463e4,d70bce4e17f5b4fb0821755098d040a52e3463e4..68b75684c7b62bed68fdcf3efd4c50b878584f05
@@@ -56,9 -56,9 +56,10 @@@ public class XamlParserTest 
        private void makeGoBang(string s)
        {
                XamlNode n;
--              XamlParser p = new XamlParser(new StringReader(s));
++              object p = buildParser(new StringReader(s));
                do {
--                      n = p.GetNextNode();
++                      n = getNextNode(p);
++//                    Process.Start("xmessage " + n.GetType());
                } while (!(n is XamlDocumentEndNode));
        }
  
        {
                string s = "<ConsoleApp xmlns=\"console\"></ConsoleApp>";
                XamlNode n;
--              XamlParser p = new XamlParser(new StringReader(MAPPING + s));
++              object p = buildParser(new StringReader(MAPPING + s));
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlDocumentStartNode, "A1");
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlElementStartNode, "B1");
                Assert.AreEqual(0, n.Depth, "B2");
                Assert.AreEqual(((XamlElementStartNode)n).ElementType, typeof(ConsoleApp), "B3");
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlElementEndNode, "C1");
                
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlDocumentEndNode, "D1");
  
        }
                string s = "<ConsoleApp xmlns=\"console\" xmlns:x=\"http://schemas.microsoft.com/winfx/xaml/2005\" x:Class=\"nnn\">\n"+
                        "</ConsoleApp>";
                XamlNode n;
--              XamlParser p = new XamlParser(new StringReader(MAPPING + s));
++              object p = buildParser(new StringReader(MAPPING + s));
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlDocumentStartNode, "A1");
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlElementStartNode, "B1");
                Assert.AreEqual(0, n.Depth, "B2");
                Assert.AreEqual("nnn", ((XamlElementStartNode)n).name, "B3");
                Assert.AreEqual(((XamlElementStartNode)n).ElementType, typeof(ConsoleApp), "B4");
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlElementEndNode, "C1");
                
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlDocumentEndNode, "D1");
        }
        
                        "</ConsoleApp>";
  
                XamlNode n;
--              XamlParser p = new XamlParser(new StringReader(MAPPING + s));
++              object p = buildParser(new StringReader(MAPPING + s));
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlDocumentStartNode);
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlElementStartNode);
                Assert.AreEqual(n.Depth, 0);
                Assert.AreEqual(((XamlElementStartNode)n).ElementType, typeof(ConsoleApp));
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlElementStartNode);
                Assert.AreEqual(n.Depth, 1);
                Assert.AreEqual(((XamlElementStartNode)n).ElementType, typeof(ConsoleWriter));
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlElementEndNode);
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlElementEndNode);
                
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlDocumentEndNode);
  
        }
                        "</ConsoleApp>";
  
                XamlNode n;
--              XamlParser p = new XamlParser(new StringReader(MAPPING + s));
++              object p = buildParser(new StringReader(MAPPING + s));
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlDocumentStartNode, "A1");
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlElementStartNode, "B1");
                Assert.AreEqual(n.Depth, 0, "B2");
                Assert.AreEqual(((XamlElementStartNode)n).ElementType, typeof(ConsoleApp), "B3");
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlElementStartNode, "C1");
                Assert.AreEqual(1, n.Depth, "C2");
                Assert.AreEqual("XXX", ((XamlElementStartNode)n).name, "C3");
                Assert.AreEqual(((XamlElementStartNode)n).ElementType, typeof(ConsoleWriter), "C4");
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlElementEndNode, "D1");
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlElementEndNode, "E1");
                
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlDocumentEndNode, "F1");
  
        }
                        "</ConsoleApp>";
  
                XamlNode n;
--              XamlParser p = new XamlParser(new StringReader(MAPPING + s));
++              object p = buildParser(new StringReader(MAPPING + s));
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlDocumentStartNode);
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlElementStartNode);
                Assert.AreEqual(n.Depth, 0);
                Assert.AreEqual(((XamlElementStartNode)n).ElementType, typeof(ConsoleApp));
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlElementStartNode);
                Assert.AreEqual(n.Depth, 1);
                Assert.AreEqual(((XamlElementStartNode)n).ElementType, typeof(ConsoleWriter));
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlTextNode);
                Assert.AreEqual(((XamlTextNode)n).TextContent, "Hello");
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlElementEndNode);
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlElementEndNode);
                
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlDocumentEndNode);
  
        }
                        "</ConsoleApp>";
  
                XamlNode n;
--              XamlParser p = new XamlParser(new StringReader(MAPPING + s));
++              object p = buildParser(new StringReader(MAPPING + s));
  
                basicPropertyTestStream(p, 0);
        }
                        "<ConsoleWriter.Text>Hello</ConsoleWriter.Text>\n" +
                        "</ConsoleWriter>\n" +
                        "</ConsoleApp>";
--              XamlParser p = new XamlParser(new StringReader(MAPPING + s));
++              object p = buildParser(new StringReader(MAPPING + s));
  
                basicPropertyTestStream(p, 1);
        }
  
  
  
--      private void basicPropertyTestStream(XamlParser p, int depthIncreaseForProperty)
++      private void basicPropertyTestStream(object p, int depthIncreaseForProperty)
        {
                XamlNode n;
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlDocumentStartNode, "A1");
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlElementStartNode, "B1");
                Assert.AreEqual(0, n.Depth, "B2");
                Assert.AreEqual(((XamlElementStartNode)n).ElementType, typeof(ConsoleApp), "B3");
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlElementStartNode, "C1");
                Assert.AreEqual(1, n.Depth, "C2");
                Assert.AreEqual(((XamlElementStartNode)n).ElementType, typeof(ConsoleWriter), "C3");
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlPropertyNode, "D1");
                Assert.AreEqual(1 + depthIncreaseForProperty, n.Depth, "D2");
                Assert.AreEqual(((XamlPropertyNode)n).PropInfo, typeof(ConsoleWriter).GetProperty("Text"), "D3");
                
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlTextNode, "E1");
                Assert.AreEqual(((XamlTextNode)n).TextContent, "Hello", "E2");
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlElementEndNode, "F1");
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlElementEndNode, "F2");
                
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlDocumentEndNode, "F3");
  
        }
                        "</ConsoleApp>";
  
                XamlNode n;
--              XamlParser p = new XamlParser(new StringReader(MAPPING + s));
++              object p = buildParser(new StringReader(MAPPING + s));
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlDocumentStartNode);
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlElementStartNode);
                Assert.AreEqual(n.Depth, 0);
                Assert.AreEqual(((XamlElementStartNode)n).ElementType, typeof(ConsoleApp));
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlElementStartNode);
                Assert.AreEqual(n.Depth, 1);
                Assert.AreEqual(((XamlElementStartNode)n).ElementType, typeof(ConsoleWriter));
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlPropertyNode);
                Assert.AreEqual(((XamlPropertyNode)n).DP, ConsoleApp.RepetitionsProperty);
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlTextNode);
                Assert.AreEqual(((XamlTextNode)n).TextContent, "3");
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlElementEndNode);
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlElementEndNode);
                
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlDocumentEndNode);
  
        }
                        "</ConsoleApp>";
  
                XamlNode n;
--              XamlParser p = new XamlParser(new StringReader(MAPPING + s));
++              object p = buildParser(new StringReader(MAPPING + s));
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlDocumentStartNode);
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlElementStartNode);
                Assert.AreEqual(n.Depth, 0);
                Assert.AreEqual(((XamlElementStartNode)n).ElementType, typeof(ConsoleApp));
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlElementStartNode);
                Assert.AreEqual(n.Depth, 1);
                Assert.AreEqual(((XamlElementStartNode)n).ElementType, typeof(ConsoleWriter));
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlPropertyNode);
                Assert.AreEqual(n.Depth, 2);
                Assert.AreEqual(((XamlPropertyNode)n).DP, ConsoleApp.RepetitionsProperty);
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlTextNode);
                Assert.AreEqual(((XamlTextNode)n).TextContent, "3");
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlElementEndNode);
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlElementEndNode);
                
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlDocumentEndNode);
  
        }
                        "<ConsoleReader.Prompt><ConsoleWriter /></ConsoleReader.Prompt>\n" +
                        "</ConsoleReader>\n" +
                        "</ConsoleApp>";
--              XamlParser p = new XamlParser(new StringReader(MAPPING + s));
++              object p = buildParser(new StringReader(MAPPING + s));
                XamlNode n;
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlDocumentStartNode, "A1");
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlElementStartNode, "B1");
                Assert.AreEqual(n.Depth, 0, "B2");
                Assert.AreEqual(((XamlElementStartNode)n).ElementType, typeof(ConsoleApp), "B3");
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlElementStartNode, "C1");
                Assert.AreEqual(1, n.Depth, "C2");
                Assert.AreEqual(((XamlElementStartNode)n).ElementType, typeof(ConsoleReader), "C3");
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlPropertyNode, "D1");
                Assert.AreEqual(2, n.Depth, "D3");
                Assert.AreEqual(((XamlPropertyNode)n).PropInfo, typeof(ConsoleReader).GetProperty("Prompt"), "D2");
                
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlElementStartNode, "E1" + n.GetType());
                Assert.AreEqual(3, n.Depth, "E2");
                Assert.AreEqual(((XamlElementStartNode)n).ElementType, typeof(ConsoleWriter), "E3");
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlElementEndNode, "F1" + n.GetType());
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlPropertyComplexEndNode, "G1");
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlElementEndNode, "H1");
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlElementEndNode, "I1");
                
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlDocumentEndNode, "J1");
  
        }
        {
                string s = "<ConsoleApp xmlns=\"console\" xmlns:x=\"http://schemas.microsoft.com/winfx/xaml/2005\" SomethingHappened=\"handleSomething\">\n"+
                        "</ConsoleApp>";
--              XamlParser p = new XamlParser(new StringReader(MAPPING + s));
++              object p = buildParser(new StringReader(MAPPING + s));
                XamlNode n;
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlDocumentStartNode, "A1");
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlElementStartNode, "B1");
                Assert.AreEqual(n.Depth, 0, "B2");
                Assert.AreEqual(((XamlElementStartNode)n).ElementType, typeof(ConsoleApp), "B3");
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlClrEventNode, "C1");
                Assert.AreEqual(((XamlClrEventNode)n).EventMember, typeof(ConsoleApp).GetEvent("SomethingHappened"), "C2");
                
                
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlElementEndNode, "D1");
                
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlDocumentEndNode, "E1");
        }
  
                string s = "<ConsoleApp xmlns=\"console\" xmlns:x=\"http://schemas.microsoft.com/winfx/xaml/2005\">\n"+
                        "<ConsoleWriter Filter=\"filterfilter\" />\n"+
                        "</ConsoleApp>";
--              XamlParser p = new XamlParser(new StringReader(MAPPING + s));
++              object p = buildParser(new StringReader(MAPPING + s));
                XamlNode n;
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlDocumentStartNode, "A1");
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlElementStartNode, "B1");
                Assert.AreEqual(n.Depth, 0, "B2");
                Assert.AreEqual(((XamlElementStartNode)n).ElementType, typeof(ConsoleApp), "B3");
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlElementStartNode, "C1");
                Assert.AreEqual(n.Depth, 1, "C2");
                Assert.AreEqual(((XamlElementStartNode)n).ElementType, typeof(ConsoleWriter), "C3");
                
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlPropertyNode, "D1");
                Assert.AreEqual(n.Depth, 1, "D2");
                Assert.AreEqual(((XamlPropertyNode)n).PropInfo, typeof(ConsoleWriter).GetProperty("Filter"), "D3");
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlClrEventNode, "E1");
                Assert.AreEqual((MemberInfo)((XamlClrEventNode)n).EventMember, typeof(ConsoleWriter).GetProperty("Filter"), "E2");
                Assert.AreEqual(((XamlClrEventNode)n).Value, "filterfilter", "E3");
                
                
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlElementEndNode, "F1");
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlElementEndNode, "G1");
                
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlDocumentEndNode, "H1");
        }
  
                string s = "<ConsoleApp xmlns=\"console\" xmlns:x=\"http://schemas.microsoft.com/winfx/xaml/2005\">\n"+
                        "<x:Code><![CDATA[Hi there <thing /> here there everywhere]]></x:Code>\n"+
                        "</ConsoleApp>";
--              XamlParser p = new XamlParser(new StringReader(MAPPING + s));
++              object p = buildParser(new StringReader(MAPPING + s));
                XamlNode n;
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlDocumentStartNode, "A1");
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlElementStartNode, "B1");
                Assert.AreEqual(((XamlElementStartNode)n).ElementType, typeof(ConsoleApp), "B3");
  
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlLiteralContentNode, "C1");
                Assert.AreEqual("Hi there <thing /> here there everywhere", ((XamlLiteralContentNode)n).Content, "C2");
                
                
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlElementEndNode, "D1");
                
--              n = p.GetNextNode();
++              n = getNextNode(p);
                Assert.IsTrue(n is XamlDocumentEndNode, "E1");
  
        }
                makeGoBang(MAPPING + s);
        }
  
--}
--
--
--
--abstract class Happening {
--      // this space deliberately left blank
--}
--
--class CreateTopLevelHappening : Happening
--{
--      public Type parent;
--      public string className;
--      public CreateTopLevelHappening(Type parent, string name) {
--              this.parent = parent;
--              this.className = name;
--      }
--}
--
--class CreateObjectHappening : Happening
--{
--      public Type type;
--      public string objectName;
--      public CreateObjectHappening(Type type, string name) {
--              this.type = type;
--              this.objectName = name;
--      }
--}
--
--class CreateObjectTextHappening : Happening
--{
--      public string text;
--      public CreateObjectTextHappening(string text) {
--              this.text = text;
--      }
--}
--
--class EndObjectHappening : Happening
--{
--      // this space deliberately left blank
--}
--
--class CreatePropertyHappening : Happening
--{
--      public PropertyInfo property;
--      public CreatePropertyHappening(PropertyInfo property){
--              this.property = property;
--      }
--}
--
--class CreatePropertyTextHappening : Happening
--{
--      public string text;
--      public Type propertyType;
--      public CreatePropertyTextHappening(string text, Type propertyType){
--              this.text = text;
--              this.propertyType = propertyType;
--      }
--}
--
--class CreatePropertyObjectHappening : Happening
--{
--      public Type type;
--      public string objectName;
--
--      public CreatePropertyObjectHappening(Type type, string objectName) {
--              this.type = type;
--              this.objectName = objectName;
--      }
--}
--class EndPropertyObjectHappening : Happening
--{
--      public Type type;
--
--      public EndPropertyObjectHappening(Type type) {
--              this.type = type;
--      }
--}
--class CreatePropertyDelegateHappening : Happening
--{
--      public string functionName;
--      public Type propertyType;
--
--      public CreatePropertyDelegateHappening(string functionName, Type propertyType) {
--              this.functionName = functionName;
--              this.propertyType = propertyType;
--      }
--}
--
--class EndPropertyHappening : Happening
--{
--      // this space deliberately left blank
--}
--
--class CreateEventHappening : Happening
--{
--      public EventInfo evt;
--      public CreateEventHappening(EventInfo evt) {
--              this.evt = evt;
--      }
--}
--
--class CreateEventDelegateHappening : Happening
--{
--      public string functionName;
--      public Type eventDelegateType;
--      public CreateEventDelegateHappening(string functionName, Type eventDelegateType) {
--              this.functionName = functionName;
--              this.eventDelegateType = eventDelegateType;
--      }
--}
--
--class EndEventHappening : Happening
--{
--      // this space deliberately left blank
--}
--
--class CreateDependencyPropertyHappening : Happening
--{
--      public Type attachedTo;
--      public string propertyName;
--      public Type propertyType;
--      public CreateDependencyPropertyHappening(Type attachedTo, string propertyName, Type propertyType) {
--              this.attachedTo = attachedTo;
--              this.propertyName = propertyName;
--              this.propertyType = propertyType;
--      }
--}
--
--class CreateDependencyPropertyTextHappening : Happening
--{
--      public string text;
--      public Type propertyType;
--      public CreateDependencyPropertyTextHappening(string text, Type propertyType) {
--              this.text = text;
--              this.propertyType = propertyType;
--      }
--}
--
--class EndDependencyPropertyHappening : Happening
--{
--      // this space deliberately left blank
--}
--
--class CreateCodeHappening : Happening
--{
--      public string code;
--      public CreateCodeHappening(string code) {
--              this.code = code;
--      }
--}
--
--class FinishHappening : Happening
--{
--      // this space deliberately left blank
--}
--
--              
--class ParserTester : IXamlWriter {
--      string document;
--      Happening[] happenings;
--      int c;
--      public ParserTester(string document, params Happening[] happenings)
--      {
--              this.document = document;
--              this.happenings = happenings;
--              this.c = 0;
--      }
--      public void Test()
--      {
--/*            XamlParser p = new XamlParser(new StringReader(document),
--                              this);
--              p.Parse();
--              // if this fails, then we haven't consumed all the happenings
--              Assert.AreEqual(happenings.Length, c);*/
--              Assert.IsTrue(false);
--      }
--      Happening getHappening()
++      XamlNode getNextNode(object p)
        {
--              Assert.IsFalse(c >= happenings.Length, "not enough happenings in list");
--              return happenings[c++];
++              MethodInfo getter = p.GetType().GetMethod("GetNextNode");
++              Assert.IsTrue(getter != null, "Couldn't get next-node-getter");
++              try {
++                      XamlNode n = (XamlNode)getter.Invoke(p, null);
++                      Assert.IsTrue(n != null, "Couldn't get next node");
++                      return n;
++              } catch (TargetInvocationException ex) {
++                      throw ex.InnerException;
++              }
        }
  
--      private void AssertSubclass(Type parent, bool consume)
--      {
--              Assert.IsFalse(c >= happenings.Length, "not enough happenings in list");
--              Happening child = happenings[c];
--
--              Debug.WriteLine("WRITER CURRENT EXPECTED THING: " + child.GetType());
--//            
--              if (child.GetType() != parent)
--                      Assert.Fail("The method called was a " + parent + ", but was expecting a " + child.GetType());
--              if (consume)
--                      c++;
--      }
--      private void d(string step)
++      object buildParser(TextReader input)
        {
--              Debug.WriteLine("WRITER IN STEP" + step);
++              Type xamlParserType = (Type)typeof(Mono.Windows.Serialization.CodeWriter).GetField("xamlParserType", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null);
++              Assert.IsTrue(xamlParserType != null, "couldn't get type of parser");
++              object p = Activator.CreateInstance(xamlParserType, new object[] { input});
++              Assert.IsTrue(p != null, "couldn't get instance of parser");
++              return p;
        }
  
--
--      public void CreateTopLevel(Type parent, string className)
--      {
--              d("CreateTopLevel");
--              AssertSubclass(typeof(CreateTopLevelHappening), false);
--              
--              CreateTopLevelHappening h = (CreateTopLevelHappening)getHappening();
--              Assert.AreEqual(h.parent, parent);
--              Assert.AreEqual(h.className, className);
--      }
--
--      public void CreateObject(Type type, string objectName){
--              d("CreateObject");
--              AssertSubclass(typeof(CreateObjectHappening), false);
--              
--              CreateObjectHappening h = (CreateObjectHappening)getHappening();
--              Assert.AreEqual(h.type, type);
--              Assert.AreEqual(h.objectName, objectName);
--      }
--
--      public void CreateObjectText(string text){
--              d("CreateObjectText");
--              AssertSubclass(typeof(CreateObjectTextHappening), false);
--              
--              CreateObjectTextHappening h = (CreateObjectTextHappening)getHappening();
--              Assert.AreEqual(h.text, text);
--      }
--
--      public void EndObject(){
--              d("EndObject");
--              AssertSubclass(typeof(EndObjectHappening), true);
--      }
--
--      public void CreateProperty(PropertyInfo property){
--              d("CreateProperty");
--              AssertSubclass(typeof(CreatePropertyHappening), false);
--              
--              CreatePropertyHappening h = (CreatePropertyHappening)getHappening();
--              Assert.AreEqual(h.property, property);
--      }
--
--      public void CreatePropertyObject(Type type, string objectName){
--              d("CreatePropertyObject");
--              AssertSubclass(typeof(CreatePropertyObjectHappening), false);
--
--              CreatePropertyObjectHappening h = (CreatePropertyObjectHappening)getHappening();
--              Assert.AreEqual(h.type, type);
--              Assert.AreEqual(h.objectName, objectName);
--      }
--      public void EndPropertyObject(Type type) {
--              d("EndPropertyObject");
--              AssertSubclass(typeof(EndPropertyObjectHappening), false);
--
--              EndPropertyObjectHappening h = (EndPropertyObjectHappening)getHappening();
--              Assert.AreEqual(h.type, type);
--      }
--
--      public void CreatePropertyText(string text, Type propertyType){
--              d("CreatePropertyText");
--              AssertSubclass(typeof(CreatePropertyTextHappening), false);
--              
--              CreatePropertyTextHappening h = (CreatePropertyTextHappening)getHappening();
--              Assert.AreEqual(h.text, text);
--              Assert.AreEqual(h.propertyType, propertyType);
--      }
--
--      public void CreatePropertyDelegate(string functionName, Type propertyType){
--              d("CreatePropertyDelegate");
--              AssertSubclass(typeof(CreatePropertyDelegateHappening), false);
--
--              CreatePropertyDelegateHappening h = (CreatePropertyDelegateHappening)getHappening();
--              Assert.AreEqual(h.functionName, functionName);
--              Assert.AreEqual(h.propertyType, propertyType);
--      }
--
--      public void EndProperty(){
--              d("EndProperty");
--              AssertSubclass(typeof(EndPropertyHappening), true);
--      }
--
--
--      public void CreateEvent(EventInfo evt){
--              d("CreateEvent");
--              AssertSubclass(typeof(CreateEventHappening), false);
--
--              CreateEventHappening h = (CreateEventHappening)getHappening();
--              Assert.AreEqual(h.evt, evt);
--      }
--
--      public void CreateEventDelegate(string functionName, Type eventDelegateType){
--              d("CreateEventDelegate");
--              AssertSubclass(typeof(CreateEventDelegateHappening), false);
--              
--              CreateEventDelegateHappening h = (CreateEventDelegateHappening)getHappening();
--              Assert.AreEqual(h.functionName, functionName);
--              Assert.AreEqual(h.eventDelegateType, eventDelegateType);
--      }
--
--      public void EndEvent(){
--              d("EndEvent");
--              AssertSubclass(typeof(EndEventHappening), true);
--      }
--
--
--      public void CreateDependencyProperty(Type attachedTo, string propertyName, Type propertyType){
--              d("CreateDependencyProperty");
--              AssertSubclass(typeof(CreateDependencyPropertyHappening), false);
--              
--              CreateDependencyPropertyHappening h = (CreateDependencyPropertyHappening)getHappening();
--              Assert.AreEqual(h.attachedTo, attachedTo);
--              Assert.AreEqual(h.propertyName, propertyName);
--              Assert.AreEqual(h.propertyType, propertyType);
--      }
--
--      public void CreateDependencyPropertyText(string text, Type propertyType){
--              d("CreateDependencyPropertyText");
--              AssertSubclass(typeof(CreateDependencyPropertyTextHappening), false);
--              
--              CreateDependencyPropertyTextHappening h = (CreateDependencyPropertyTextHappening)getHappening();
--              Assert.AreEqual(h.text, text);
--              Assert.AreEqual(h.propertyType, propertyType);
--      }
--
--      public void EndDependencyProperty(){
--              d("EndDependencyProperty");
--              AssertSubclass(typeof(EndDependencyPropertyHappening), true);
--      }
--
--
--      public void CreateCode(string code){
--              d("CreateCode");
--              AssertSubclass(typeof(CreateCodeHappening), false);
--
--              CreateCodeHappening h = (CreateCodeHappening)getHappening();
--              Assert.AreEqual(h.code, code);
--      }
--
--
--      public void Finish()
--      {
--              d("Finish");
--              AssertSubclass(typeof(FinishHappening), true);
--      }
--
--
  }
  
  
++
  }
index c7c1823b8bdd310ed10e7a1474a865f42f663fb9,c7c1823b8bdd310ed10e7a1474a865f42f663fb9..5d60c92a12e176dd45e92aebd517f94dc5abdada
@@@ -1,3 -1,3 +1,8 @@@
++2005-08-26  Iain McCoy  <iain@mccoy.id.au>
++
++      * demo/runtimetest.cs: use the newly-renamed Parser class instead of
++      the interim ObjectWriter
++
  2005-08-23  Iain McCoy  <iain@mccoy.id.au>
  
        * xamlc.cs: consume the new CodeWriter interface
index fc310b6e71232df0226899cabe74e12e5163704a,fc310b6e71232df0226899cabe74e12e5163704a..e8c20e16a06672d286a0a3a403ae490d4fcfc14d
@@@ -1,11 -1,11 +1,10 @@@
  using Xaml.TestVocab.Console;
  using System.Xml;
  using System.Windows.Serialization;
--using Mono.Windows.Serialization;
  
  class RuntimeTest {
        public static void Main(string[] args) {
--              ConsoleApp c = (ConsoleApp)ObjectWriter.Parse(new XmlTextReader("runtimetest.xaml"));
++              ConsoleApp c = (ConsoleApp)Parser.LoadXml(new XmlTextReader("runtimetest.xaml"));
  
                c.Run();
        }