From 4e7a57aca95619b2e7d3ee6a090152cd90941ede Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Mon, 12 May 2008 11:25:32 +0000 Subject: [PATCH] Support markup extensions in object syntax. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@3072 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Tests/XamlDom/SimpleLoadTests.cs | 30 +++++++++++++++++++ .../WpfDesign.XamlDom/Project/XamlObject.cs | 7 ++++- .../WpfDesign.XamlDom/Project/XamlParser.cs | 8 ++++- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/SimpleLoadTests.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/SimpleLoadTests.cs index ea9ee5de9c..340309dbbd 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/SimpleLoadTests.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/SimpleLoadTests.cs @@ -255,6 +255,36 @@ namespace ICSharpCode.WpfDesign.Tests.XamlDom xmlns:t=""" + XamlTypeFinderTests.XamlDomTestsNamespace + @""" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" ObjectProp=""{x:Null}""> + + "); + } + + [Test] + public void ExampleClassObjectPropWithExplicitMarkupExtension() + { + TestLoading(@" + + + + + + "); + } + + [Test] + public void ExampleClassObjectPropWithExplicitMarkupExtension2() + { + TestLoading(@" + + + + "); } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs index 391e849165..b689cf97f5 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs @@ -9,6 +9,7 @@ using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; +using System.Windows.Markup; using System.Xml; namespace ICSharpCode.WpfDesign.XamlDom @@ -50,7 +51,11 @@ namespace ICSharpCode.WpfDesign.XamlDom #region XamlPropertyValue implementation internal override object GetValueFor(XamlPropertyInfo targetProperty) { - return instance; + if (instance is MarkupExtension) { + return ((MarkupExtension)instance).ProvideValue(new XamlTypeResolverProvider(this)); + } else { + return instance; + } } internal override XmlNode GetNodeForCollection() diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs index 53d4a27bf4..3c837ab7f2 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs @@ -133,7 +133,13 @@ namespace ICSharpCode.WpfDesign.XamlDom XamlObject ParseObject(XmlElement element) { - Type elementType = FindType(element.NamespaceURI, element.LocalName); + Type elementType = settings.TypeFinder.GetType(element.NamespaceURI, element.LocalName); + if (elementType == null) { + elementType = settings.TypeFinder.GetType(element.NamespaceURI, element.LocalName + "Extension"); + if (elementType == null) { + throw new XamlLoadException("Cannot find type " + element.Name); + } + } XmlSpace oldXmlSpace = currentXmlSpace; XamlObject parentXamlObject = currentXamlObject;