Browse Source

Support markup extensions in object syntax.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@3072 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 17 years ago
parent
commit
4e7a57aca9
  1. 30
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/SimpleLoadTests.cs
  2. 7
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs
  3. 8
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs

30
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/SimpleLoadTests.cs

@ -255,6 +255,36 @@ namespace ICSharpCode.WpfDesign.Tests.XamlDom @@ -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}"">
</t:ExampleClass>
");
}
[Test]
public void ExampleClassObjectPropWithExplicitMarkupExtension()
{
TestLoading(@"
<t:ExampleClass
xmlns=""http://schemas.microsoft.com/netfx/2007/xaml/presentation""
xmlns:t=""" + XamlTypeFinderTests.XamlDomTestsNamespace + @"""
xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"">
<t:ExampleClass.ObjectProp>
<x:Type TypeName=""t:ExampleClass""/>
</t:ExampleClass.ObjectProp>
</t:ExampleClass>
");
}
[Test]
public void ExampleClassObjectPropWithExplicitMarkupExtension2()
{
TestLoading(@"
<t:ExampleClass
xmlns=""http://schemas.microsoft.com/netfx/2007/xaml/presentation""
xmlns:t=""" + XamlTypeFinderTests.XamlDomTestsNamespace + @"""
xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"">
<t:ExampleClass.ObjectProp>
<x:TypeExtension TypeName=""t:ExampleClass""/>
</t:ExampleClass.ObjectProp>
</t:ExampleClass>
");
}

7
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs

@ -9,6 +9,7 @@ using System; @@ -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 @@ -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()

8
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs

@ -133,7 +133,13 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -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;

Loading…
Cancel
Save