diff options
author | Iain McCoy <iainmc@mono-cvs.ximian.com> | 2005-07-15 11:49:27 +0400 |
---|---|---|
committer | Iain McCoy <iainmc@mono-cvs.ximian.com> | 2005-07-15 11:49:27 +0400 |
commit | 8b779ce90b2d1606eb89501b6e53be4701776d5b (patch) | |
tree | 5a82f4c59112b7217aca95d7fc233ff77546e2e6 /mcs/class/PresentationFramework | |
parent | 5ebe857edd7aff8bb42acf89b4f554e6d78e3fbe (diff) |
2005-07-15 Iain McCoy <iain@mccoy.id.au>
* System.Windows.Serialization/Mapper.cs: make assembly loading more
resilient
* Mono.Windows.Serialization/ObjectWriter.cs: do conversions from
strings and support dependency properties
* demo/test.xaml: enhanced testing of complex objects as property
values and documented test file.
* demo/runtimetest.xaml: added dependency property test
svn path=/trunk/mcs/; revision=47329
Diffstat (limited to 'mcs/class/PresentationFramework')
3 files changed, 40 insertions, 8 deletions
diff --git a/mcs/class/PresentationFramework/ChangeLog b/mcs/class/PresentationFramework/ChangeLog index 35d15bee2e2..0bdd7cf8783 100644 --- a/mcs/class/PresentationFramework/ChangeLog +++ b/mcs/class/PresentationFramework/ChangeLog @@ -1,5 +1,12 @@ 2005-07-15 Iain McCoy <iain@mccoy.id.au> + * System.Windows.Serialization/Mapper.cs: make assembly loading more + resilient + * Mono.Windows.Serialization/ObjectWriter.cs: do conversions from + strings and support dependency properties + +2005-07-15 Iain McCoy <iain@mccoy.id.au> + * Mono.Windows.Serialization/CodeWriter.cs: don't try to convert objects into their parent types. diff --git a/mcs/class/PresentationFramework/Mono.Windows.Serialization/ObjectWriter.cs b/mcs/class/PresentationFramework/Mono.Windows.Serialization/ObjectWriter.cs index f024812150b..67b988345fe 100644 --- a/mcs/class/PresentationFramework/Mono.Windows.Serialization/ObjectWriter.cs +++ b/mcs/class/PresentationFramework/Mono.Windows.Serialization/ObjectWriter.cs @@ -32,6 +32,7 @@ using System.IO; using System.Collections; using System.CodeDom; using System.CodeDom.Compiler; +using System.ComponentModel; using System.Windows.Serialization; namespace Mono.Windows.Serialization { @@ -66,12 +67,18 @@ namespace Mono.Windows.Serialization { public void CreateDependencyProperty(Type attachedTo, string propertyName, Type propertyType) { - throw new NotImplementedException(); + objects.Add(attachedTo); + objects.Add(propertyName); } public void EndDependencyProperty() { - throw new NotImplementedException(); + object value = pop(); + string propertyName = (string)pop(); + Type attachedTo = (Type)pop(); + + MethodInfo setter = attachedTo.GetMethod("Set" + propertyName); + setter.Invoke(null, new object[] { objects[objects.Count - 1], value}); } public void CreateElementText(string text) @@ -96,11 +103,14 @@ namespace Mono.Windows.Serialization { public void CreatePropertyText(string text, Type propertyType) { - if (propertyType != typeof(string)) - throw new NotImplementedException(); + object value = text; + if (propertyType != typeof(string)) { + TypeConverter tc = TypeDescriptor.GetConverter(propertyType); + value = tc.ConvertFromString(text); + } PropertyInfo p = (PropertyInfo)objects[objects.Count-1]; object o = objects[objects.Count-2]; - p.SetValue(o, text, null); + p.SetValue(o, value, null); } public void CreatePropertyObject(Type type, string name) @@ -115,7 +125,12 @@ namespace Mono.Windows.Serialization { // top of stack is reference to an attached property public void CreateDependencyPropertyText(string text, Type propertyType) { - throw new NotImplementedException(); + object value = text; + if (propertyType != typeof(string)) { + TypeConverter tc = TypeDescriptor.GetConverter(propertyType); + value = tc.ConvertFromString(text); + } + objects.Add(value); } public void EndObject() @@ -141,5 +156,12 @@ namespace Mono.Windows.Serialization { { throw new NotImplementedException(); } + + private object pop() + { + object v = objects[objects.Count - 1]; + objects.RemoveAt(objects.Count - 1); + return v; + } } } diff --git a/mcs/class/PresentationFramework/System.Windows.Serialization/Mapper.cs b/mcs/class/PresentationFramework/System.Windows.Serialization/Mapper.cs index 4f1683a52a5..c4ee2af0379 100644 --- a/mcs/class/PresentationFramework/System.Windows.Serialization/Mapper.cs +++ b/mcs/class/PresentationFramework/System.Windows.Serialization/Mapper.cs @@ -135,9 +135,12 @@ namespace System.Windows.Serialization { { if (assemblyPath.ContainsKey(name)) name = (string)assemblyPath[name]; - Assembly result = Assembly.LoadFrom(name); - if (result == null) + Assembly result; + try { + result = Assembly.LoadFrom(name); + } catch { result = Assembly.Load(name); + } if (result == null) throw new Exception("Could not find assembly with name " + name); else |