|
|
|
|
@ -328,52 +328,52 @@ namespace ICSharpCode.WpfDesign.XamlDom
@@ -328,52 +328,52 @@ 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"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
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) { |
|
|
|
|
if (childElement.NamespaceURI == XamlConstants.XamlNamespace) |
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
if (ObjectChildElementIsPropertyElement(childElement)) { |
|
|
|
|
ParseObjectChildElementAsPropertyElement(obj, childElement, defaultProperty); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (initializeFromTextValueInsteadOfConstructor != null) |
|
|
|
|
continue; |
|
|
|
|
XamlPropertyValue childValue = ParseValue(childNode); |
|
|
|
|
if (childValue != null) { |
|
|
|
|
if (collectionProperty != null) { |
|
|
|
|
collectionProperty.ParserAddCollectionElement(collectionPropertyElement, childValue); |
|
|
|
|
CollectionSupport.AddToCollection(collectionType, collectionInstance, childValue); |
|
|
|
|
} else { |
|
|
|
|
if (defaultProperty == null) |
|
|
|
|
throw new XamlLoadException("This element does not have a default value, cannot assign to it"); |
|
|
|
|
|
|
|
|
|
if (isDefaultValueSet) |
|
|
|
|
throw new XamlLoadException("default property may have only one value assigned"); |
|
|
|
|
|
|
|
|
|
obj.AddProperty(new XamlProperty(obj, defaultProperty, childValue)); |
|
|
|
|
isDefaultValueSet = true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
{ |
|
|
|
|
foreach (XmlNode childNode in elementChildNodes) { |
|
|
|
|
XmlElement childElement = childNode as XmlElement; |
|
|
|
|
if (childElement != null) { |
|
|
|
|
if (childElement.NamespaceURI == XamlConstants.XamlNamespace) |
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
if (ObjectChildElementIsPropertyElement(childElement)) { |
|
|
|
|
ParseObjectChildElementAsPropertyElement(obj, childElement, defaultProperty); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (initializeFromTextValueInsteadOfConstructor != null) |
|
|
|
|
continue; |
|
|
|
|
XamlPropertyValue childValue = ParseValue(childNode); |
|
|
|
|
if (childValue != null) { |
|
|
|
|
if (collectionProperty != null) { |
|
|
|
|
collectionProperty.ParserAddCollectionElement(collectionPropertyElement, childValue); |
|
|
|
|
CollectionSupport.AddToCollection(collectionType, collectionInstance, childValue); |
|
|
|
|
} else { |
|
|
|
|
if (defaultProperty == null) |
|
|
|
|
throw new XamlLoadException("This element does not have a default value, cannot assign to it"); |
|
|
|
|
|
|
|
|
|
if (isDefaultValueSet) |
|
|
|
|
throw new XamlLoadException("default property may have only one value assigned"); |
|
|
|
|
|
|
|
|
|
obj.AddProperty(new XamlProperty(obj, defaultProperty, childValue)); |
|
|
|
|
isDefaultValueSet = true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
IEnumerable<XmlNode> GetNormalizedChildNodes(XmlElement element) |
|
|
|
|
@ -599,10 +599,10 @@ namespace ICSharpCode.WpfDesign.XamlDom
@@ -599,10 +599,10 @@ namespace ICSharpCode.WpfDesign.XamlDom
|
|
|
|
|
return element.LocalName.Contains("."); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static bool ObjectChildElementIsCollectionInstance(XmlElement element, Type collectionType) |
|
|
|
|
{ |
|
|
|
|
return element.Name == collectionType.Name; |
|
|
|
|
} |
|
|
|
|
static bool ObjectChildElementIsCollectionInstance(XmlElement element, Type collectionType) |
|
|
|
|
{ |
|
|
|
|
return element.Name == collectionType.Name; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static bool IsElementChildACollectionForProperty(XamlTypeFinder typeFinder, XmlElement element, XamlPropertyInfo propertyInfo) |
|
|
|
|
{ |
|
|
|
|
|