Browse Source

bugfix : Collection Instance == 0 fixes: Animation1 Unit Test

pull/584/head
jkuehner 12 years ago
parent
commit
e53c26fb04
  1. 22
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs

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

@ -22,6 +22,7 @@ using System.ComponentModel; @@ -22,6 +22,7 @@ using System.ComponentModel;
using System.Globalization;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Windows;
using System.Windows.Interop;
@ -327,6 +328,21 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -327,6 +328,21 @@ namespace ICSharpCode.WpfDesign.XamlDom
}
}
if (collectionType != null && collectionInstance == null && elementChildNodes.Count() == 1)
{
var firstChild = elementChildNodes.First() as XmlElement;
if (ObjectChildElementIsCollectionInstance(firstChild, collectionType))
{
collectionInstance = ParseObject(firstChild);
collectionProperty.PropertyValue = (XamlPropertyValue) collectionInstance;
}
else
{
throw new XamlLoadException("Collection Instance is null");
}
}
else
{
foreach (XmlNode childNode in elementChildNodes) {
XmlElement childElement = childNode as XmlElement;
if (childElement != null) {
@ -357,6 +373,7 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -357,6 +373,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
}
}
}
}
}
IEnumerable<XmlNode> GetNormalizedChildNodes(XmlElement element)
@ -582,6 +599,11 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -582,6 +599,11 @@ namespace ICSharpCode.WpfDesign.XamlDom
return element.LocalName.Contains(".");
}
static bool ObjectChildElementIsCollectionInstance(XmlElement element, Type collectionType)
{
return element.Name == collectionType.Name;
}
static bool IsElementChildACollectionForProperty(XamlTypeFinder typeFinder, XmlElement element, XamlPropertyInfo propertyInfo)
{
return element.ChildNodes.Count == 1 && propertyInfo.ReturnType.IsAssignableFrom(FindType(typeFinder, element.FirstChild.NamespaceURI, element.FirstChild.LocalName));

Loading…
Cancel
Save